I want to make an upgrade level for my weight but this script doesn't work, help me please! The output said this : " Players.TheKakYTArmy.PlayerGui.ShopGui.Box.Upgrade.Script:2: attempt to index local 'player' (a nil value)"
script.Parent.MouseButton1Click:Connect(function(player) if player.leaderstats.Cash.Value >= 100 then game.StarterPack.Weight.Level.Value = game.StarterPack.Weight.Level.Value + 1 player.leaderstats.Cash.Vlue = player.leaderstats.Cash.Value - 100 end end)
I don't believe MouseButton1Click has any set parameters, you also made a couple mistakes within your script. Below is code that should work:
local player = game.Players.LocalPlayer -- assuming leaderstats is held within the player's folder script.Parent.MouseButton1Click:Connect(function() if player:WaitForChild("leaderstats").Cash.Value >= 100 then game.StarterPack.Weight.Level.Value = game.StarterPack.Weight.Level.Value + 1 player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 100 end end)
I found the script myself, the script is actually ~~~~~~~~~~~~~~~~~ player = script.Parent.Parent.Parent.Parent.Parent money = player.leaderstats.Cash price = game.StarterPack.Weight.Level.Value * 100
function buy() if money.Value >= price then money.Value = money.Value - price game.StarterPack.Weight.Level.Value = game.StarterPack.Weight.Level.Value + 1
end end script.Parent.MouseButton1Down:connect(buy)
~~~~~~~~~~~~~~~~~ Thank you for trying, but nothing worked so I just made the script myself.
local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() if player.leaderstats.Cash.Value >= 100 then game.StarterPack.Weight.Level.Value = game.StarterPack.Weight.Level.Value + 1 player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 100 end end)