Your supposed to put a space between adding a value. Example + 1 instead of +1
It adds cash to the player already, but it won’t do the second part. Anything after else won’t work.
What is the .5 for? 30charsssss
It is a delay system to prevent autoclickers from ruining the game. It simply just disables the button for half a second.
You gonna have to ask some other people about this. I would suggest asking this question to Kamlkaze_kid
Thank you for the suggestion! 30charsssssssssss
LUA is not too picky about white space, so this would work the same with or without a space
The whole thing about this is that it is adding cash on the client side, and not the server side. You will need to implement a remote event
I am not good with events, care to explain to me what to do?
I would like to point out some things that needs to fixed:
- Changing a value in the client won’t replicate to the server, you would have to utilize remote events.
- It doesn’t matter if there is a space or not. As @DarkDanny04 said, LUA is not too picky.
Seems like @DarkDanny04 had already said my word
What remote would I have to use and how would I have to use it?
You can either use RemoteEvents or RemoteFunctions. You can learn about it here: Custom Events and Callbacks | Documentation - Roblox Creator Hub
Thank you! 30charssssssssssssssssssssssssssssssssssssss
What is multiValue? Are you expecting it to change while the game is running, and what is the Value of it when the game starts?
The value of it when the game starts is 0, which you gain by stepping on a button when you reach enough cash to buy it.
You should replace
local multiValue = player.leaderstats.Multi.Value
with
local multiValue = player.leaderstats.Multi
As what you are effectively doing is saying
local multiValue = 0
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)
I’ve commented where I changed the script.
Thank you! 30charsssssssssssss
Does this need to be in a script or a localscript?
I’ve just made changes to the script.
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.
Thank you! 30charssssssssssssssssssssss