Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I change stats with a localscript?

Asked by
sydre 229 Moderation Voter
5 years ago

When I first started scripting, you could use a serverscript inside of StarterGui. However, that is no longer the case. Now you have to use a localscript to run any code inside of PlayerGui. The problem I have whit this is that the changes I do with a localscript seems to only happen to the client and not the server. For exaple, if I try to make a GUI where when the player clicks on it, it gives them Money, the player will recieve money after clicking on the GUI but it seems that the money only exist on the clients computer because when i try to also change the players balance with a serverscript, the players money goes back to where it was before I changed the value with a localscript. This also makes me unable to save the players progress because the DataStoreSystem cannot see the players money and can therefore, not save it.

When i try to move a object it doesn't move for everyone but only for the player that activated the localscript.

My question is, how can i fix this. Is there any way to get a localscript to make a change to the server or is there some way to use a serverscript inside of StarterGui

1
Use RemoteEvents: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events yHasteeD 1819 — 5y
0
You used to be able to use server scripts inside startergui? when was that? starmaq 1290 — 5y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago

This is a good question, cuz like this you can learn how to use Remote Events, which is a way to communicate between server and client. Using it is fearly easy.

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

And this is also used for protecting your game from exploiters

https://www.youtube.com/watch?v=C0qQ4lDa3t0&t=168s (im not sure if this has any deprecated stuff)

Happy to help!

Client/Server is a really cool mechanism that is really interesting, and I recommend learning more about it.

0
and ofc im not gonnna show you what to, i will give you what you gotta use and u go from this point starmaq 1290 — 5y
1
Thank you so much sydre 229 — 5y
0
np starmaq 1290 — 5y
0
np starmaq 1290 — 5y
Ad

Answer this question