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!
If you are trying to add an amount of cash or add value to a value, then try this.
-- Button local button = script.Parent local vbucc button.ClickDetector.MouseClick:Connect(function(player) vbucc = player.leaderstats.vbucc vbucc.Value = 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 = 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 = cash.Value + 500 player.Character:FindFirstChild("Humanoid").JumpPower = 100 end end)