Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How my script always thinks leaderstat value is always 0?

Asked by 3 years ago
Edited 3 years ago
local sellPart = script.Parent
sellPart.Touched:Connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
        local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
        if player then
            local leaderstats = player:WaitForChild("leaderstats")
            local playerGold = leaderstats.Gold
            local playerMIS = leaderstats.MoneyInStorage

            print(playerMIS.Value)

            playerMIS.Value = playerMIS.Value *1
            if playerMIS.Value > 0 then
                playerGold.Value = playerGold.Value + playerMIS.Value
                playerMIS.Value = 0
            end
        end
    end
end)

It always thinks that playerMIS.Value = 0 but it is actually another number like 10 (>0) in my leaderstat. Any way I can fix that?? Naturally playerMIS.Value increases through LocalScript while this is usual Script, maybe it is a problem?

0
its called a local script for a reason sata5pa3da 286 — 3y
0
If you are increasing through a localscript, the server can't see it. That is because localscript runs only for a client and the script (a server script) won't see it. AProgrammR 398 — 3y

Answer this question