So, I am currently making a game with a money system to buy speed/jump power. When I buy something and then press the button that gives you money, it gives my money back plus how much it is supposed to give you. Why is this happening? (the money is called vbucc, I'm gonna make all the scripts into one, seperated into comments for your viewing.
-- Button
local button = script.Parent
local vbucc
button.ClickDetector.MouseClick:Connect(function(player)
vbucc = player.leaderstats.vbucc
vbucc.Value += 5
button.BrickColor = BrickColor.new("Really red")
wait(.2)
button.BrickColor = BrickColor.new("Lime green")
end)
-- Shop Speed Button (GUI)
local player = game.Players.LocalPlayer
local button = player.PlayerGui.Shop2.MainFrame.Speed.speed2
button.MouseButton1Down:Connect(function()
local cash = player.leaderstats.vbucc
if cash.Value >= 500 then
cash.Value -= 500
player.Character:FindFirstChild("Humanoid").WalkSpeed = 32
end
end)
-- Shop Jump Button (GUI)
local player = game.Players.LocalPlayer
local button = player.PlayerGui.Shop.MainFrame.Jump.jump2
button.MouseButton1Down:Connect(function()
local cash = player.leaderstats.vbucc
if cash.Value >= 500 then
cash.Value -= 500
player.Character:FindFirstChild("Humanoid").JumpPower = 100
end
end)
Please help!

5 comments
well for one thing the variable 'vbucc' doesnt equal anything
Yup
it sets it on line 7 wdym
I don't know if this would solve the problem, but you need to use a RemoteEvent if you wanna set someones leaderstat value from a local script
it isn't a localscript, should i still use it?