Comment lier l'argent de deux leaderstats roblox

maxou2726 Messages postés 1 Date d'inscription samedi 15 juillet 2023 Statut Membre Dernière intervention 15 juillet 2023 - 15 juil. 2023 à 02:41

Bonjour, j'ai créé un serveur roblox et je me retrouve avec deux stat leader donc deux argent différent, mais je ne sais pas comment fusionner l'argent car avec le script de mon magnat je peux obtenir de l'argent dans le premier leaderstat et le dépenser pour quelque chose mais ça bloque quand je veux acheter des articles dans mon magasin de voiture car il utilise un autre leaderstats et donc une autre monnaie, que celle de mon tycoon qui m'empêche donc d'acheter une voiture merci d'avance.

voici le leaderstat que mon magnat utilise:

fonction onPlayerEntered(newPlayer)

if CTF_mode == true then

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local captures = Instance.new("IntValue")
    captures.Name = "Captures"
    captures.Value = 0


    captures.Parent = stats

    -- VERY UGLY HACK
    -- Will this leak threads?
    -- Is the problem even what I think it is (player arrived before character)?
    while true do
        if newPlayer.Character ~= nil then break end
        wait(5)
    end

    stats.Parent = newPlayer

else

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local kills = Instance.new("IntValue")
    kills.Name = "KOs"
    kills.Value = 0

    local deaths = Instance.new("IntValue")
    deaths.Name = "Wipeouts"
    deaths.Value = 0
    
    local cash = Instance.new("IntValue")
    cash.Name = "Cash"
    cash.Value = 0
    
    local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(newPlayer.Name)
    if cashmoney ~= nil then
        cashmoney.Changed:connect(function()
            cash.Value = cashmoney.Value
        end)
    end

    kills.Parent = stats
    deaths.Parent = stats
    cash.Parent = stats

    -- VERY UGLY HACK
    -- Will this leak threads?
    -- Is the problem even what I think it is (player arrived before character)?
    while true do
        if newPlayer.Character ~= nil then break end
        wait(5)
    end

    local humanoid = newPlayer.Character.Humanoid

    humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )

    -- start to listen for new humanoid
    newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )


    stats.Parent = newPlayer

end

fin

voici le leaderstat avec lequel je voudrais fusionner l'argent pour pouvoir acheter des voitures :

function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"

local score = Instance.new("IntValue")

score.Name = "Cash"
score.Value = 0

score.Parent = stats    
stats.Parent = newPlayer

fin

game.Players.ChildAdded : connect (onPlayerEntered)

voici la commande pour acheter le ca:

game.ReplicatedStorage.DealershipEvents.BuyCar.OnServerEvent:Connect(function(player,Car) local Price = game.ServerStorage.ShopCars:FindFirstChild(Car).Price.Value local Cash = player.leaderstats.Cash if Price and Cash.Value > = Prix et player.OwnedCars:FindFirstChild(Car).Value == true then Cash.Value = Cash.Value - Prix player.OwnedCars:FindFirstChild(Car).Value = true end end)