Hello. I am a scripter on my main, and I am making a button simulator where you click a button to add cash instead of adding cash every second, but my script is not working. I want it so that if you have 0 rebirths, you get 1 cash, 1 rebirth times 2 cash, 2 rebirths times 3 and so on. This is my script i have so far.
The issue is that it will not multiply 1 by the +1 of the amount of multiplier they have.
local player = game.Players.LocalPlayer
local multiValue = player.leaderstats.Multi.Value
script.Parent.MouseButton1Click:Connect(function()
if multiValue <= 0 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value +1
script.Parent.Parent.Visible = false
wait(.5)
script.Parent.Parent.Visible = true
else
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value +(2*multiValue)
script.Parent.Parent.Visible = false
wait(.5)
script.Parent.Parent.Visible = true
end
end)
And if you update multiValue.Value, it won’t update the variable with the new changes you made to it.
You should also replace all the times you use multiValue with multiValue.
local player = game.Players.LocalPlayer
local multiValue = player.leaderstats.Multi -- Made changes
script.Parent.MouseButton1Click:Connect(function()
if multiValue.Value <= 0 then
-- Communicate to server via remote event to increase money
script.Parent.Parent.Visible = false
wait(.5)
script.Parent.Parent.Visible = true
else
-- Communicate to server via remote event to increase money, multiplied by multiValue
script.Parent.Parent.Visible = false
wait(.5)
script.Parent.Parent.Visible = true
end
end)
This script should be in a LocalScript, but you should also make a RemoteEvent, and a Script, as mentioned before, changes you make on your client dont replicate to the server and other clients in this case. The server should handle adding the cash to the servers end.