Script not applying numbers to Value

I’m trying to make a script where once you click on a SurfaceGui, a Value located in the workspace has it’s value changed.

function SCRAM()
	workspace["SCRAM?"].Value = math.random(1,2)
script.Disabled = true


Everything so far is correct just except this and when I check the workspace, the value has not been added.
Anybody know the solution to this?

Hello, you need to use a Remote Event, to fire the value over to the server. Changing it on the client won’t work. What you can do is fire over your math.random result and then on the server pick that up and change the value to it.

1 Like

Could be abusable on the client, but I don’t know man, maybe do the math.random on the server?

No need to worry guys. I simply had to duplicate this:
workspace[“SCRAM?”].Value = workspace[“SCRAM?”].Value = math.random(1,2)
Thanks for your ideas!

Transfer the SCRAM() function to a serverscript, and make a remote event. Once the button get’s clicked, you fire the remote event and the server will handle the rest. Make sure to remove the script.Disabled = true line. It would look like this:

      script.Disabled = true

then on the server, you do this:

     workspace["SCRAM?"].Value = math.random(1,2)

I hope this helped you!