Hello there, I want to make a UI based system for stats just to get the hang of Roblox studio’s UI’s. I am just wondering where should I put the scripts that play around with data as I do not want players to change stats for other players (I want each individual player to have their own GUI stats). I also do not want it to be too easy for people to give themselves stats as I have seen that happen in games before. I tried looking on the dev forum and all I can find is people saying to put it in the player and inside the GUI but wouldn’t that give access to the code to players?
(I am just really confused as to which scripts goes where inside Roblox studio in general so people can’t just hack away instantly).
I made another GUI before which is broken now because of updates and a lack of time to maintain it on my end (So there is no real use for me to show a screenshot here) and I had the issue of the stats being added for everyone on the same GUI.
Any help is warmly welcomed!
Thanks in advance!
– Scripteor
– PS
(If I need to do extra steps to achieve my goal and make it overcomplicated I do not mind I need to practice coding as I am studying computer science currently.)
Alright this is what people were saying on other posts but I was not sure if it was fine or not since I have heard stuff about people putting scripts in the wrong places and it being easy to have access to. Thank you very much .
no problem. As a general way of thinking, dont work your ideas around the thought of people exploiting. It’s bound to happen, so don’t waste time over it.
Personally I would have a script located in ServerScriptService that is a handler for most data / stats. I would have the script get the player through the PlayerAdded function, and then change UI through that function:
game.Players.PlayerAdded:Connect(function(player)
player:WaitForChild("PlayerGui").ScreenGui.Frame.TextLabel.Text = "Hello World!" -- example of changing UI through this script
end)
This would be very secure also because this script is stored in the server, not the client.
You are supposed to handle anything about UI on the client, and anything else that needs to be on the server on the server. It is a very bad practice to handle it on the server like that.
Whoops! To correct my mistake previously, I would handle all stats on the server and send that information from server to client via remote events. Thanks for correcting me!
say we have our stats, coins, and we have a textlabel gui that shows how many coins you have.
However the coins increase or decrease should be done so on the server-side,
while the client-side receives those changes through something like a remote event, or detecting if the stats value has changed, and changes the textlabel from there.
You shouldn’t change the value of stats on the client-side
If I remember correctly from my previous coding sessions I have to make a RemoteEvent in ReplicatedStorage and link it to a script on the server for it to work right?
Also thank you for taking the time to help a random dude on Roblox lol.
Yeah no problem! It what I like doing for some reason.
Anyway, yes. The RemoteEvent would be located in ReplicatedStorage. This Roblox Tutorial will help you know how to fire or receive the events properly. I’ve also listed a screenshot of the segment I am referencing below: