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

Problem with leaderstats updating ?

Asked by 3 years ago
Edited 3 years ago

as the title said, leaderstats won't update properly, here are some screenshots of that what's happening

https://i.imgur.com/JQWQ49e.png / https://imgur.com/JQWQ49e

and that's the code for selling

local part = script.Parent
part.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 money = leaderstats.Cash
      local selling = leaderstats.Bricks
        if selling.Value >= 0 then
          money.Value = money.Value + selling.Value*1
          selling.Value = 0
        end
    end
    end
end)

and for buying

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function(click)
    if player.leaderstats.Cash.Value >= 50 then 
        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 50 

        game.ReplicatedStorage.Tools.Brick1:Clone().Parent = player:WaitForChild("Backpack") 
    end
end)

I hope someone knows what's going on

0
Ur buying script is good but ur selling script is wrong, Touched is not an valid member of serverscriptserver, i hoped this helped YTNilab 3 — 3y
0
Do you think using a function instead would solve the problem? kapkap27 2 — 3y

Answer this question