Data reset on change

Hello everyone,

I am running into a problem where if I give my alt account time for an upcoming game. Every second (when the timer ticks down each second) the value resets to the value it was before.

I want to be able to have people trade time but when I do it, it resets both users and goes down 1 number.

I cant get this to work does anybody know how to fix it?

I tried doing different methods of reworking code, changing data, looking on the dev forums and such but I cant find what the problem is. If anyone can tell me why its doing that and how I can fix it, I would appreciate that!

Here are some of my code.


image

Thanks :smile:

you need to set the value only on serverside
your third script is a local script that changes the value on click

that’s an issue because it’s changing only on clientside, so the change doesnt exist on the server
then, your server script with the infinite loop will lower the serverside version of the value by 1 and overwrite the clientside one

How would I change that server sided?

you could fire a remote event whenever the button is clicked
or put a server script into the gui button (assuming it’s a button in a gui from StarterGui)

If you can can you tell me what or how I should code it in (etc examples) please?

-- local script
on button clicked
   fire a remote event

-- server script
on player added
   setup the intValue

on remote event fired by somePlayer
   add 1 to the value of somePlayer's intValue