I’m a total beginner, I started coding a few weeks ago.
What do you want to achieve? - A core stat system/mechanic
Brief info:
The game’s going to include a system of stat improvement. For example let’s say Strength would improve health in 1 to 2 ratio (+1 Strength = +2 MaxHp) and Strength itself is improved by training, etc. I generally know how to do that, but the value storing system… I can’t wrap my head around it. I want to code it properly. As far as I understand to achieve security in the stats and bars I would have to store values server side, but I only know how to do that client side.
How would I approach the implementation of such system? Could you provide some concepts, tips or step by step explanation of how to achieve something like that? Like what commands to use, where to store what, how to make it secure, etc.
Like should a file with values be created whenever a player joins the server? Where do I put it?
What solutions have you tried so far? - I’ve been through a basic coding course and searched the forum for the way others implement their health bars, etc, but it seem they all store values on the client side.
You can store the values inside the player, even though the client can access it if everything is handled on the server the client’s changes won’t do any effect (since they don’t replicate to the server)
Use remote events to update the UI
Make sure all calculations and value changes are made on the server
Also health bar you can basically store entirely on the client since exploits don’t do anything to health or Max health
Great! Thank you for the response. Last thing, since, from what I understand, server scripts (calculations) affect all clients, how do I differentiate between particular players? They would need to be affected by the calculations differently, right?
Because there’s multiple player instances you won’t have to worry too much about differntiating for different players.
Everytime you call game.Players.PlayerAdded:Connect(function() it creates a different thread for each player so you can just focus on each player with the same lines of code.
So for instance if I changed a player’s XP inside their player instance it would replicate to other players but not their XP stat.
Its like if someone took a test and every student got their own seperate scores. Lets say you change someones score. Now everyone else could see that persons score but it wouldn’t affect anyone elses.
What if a player gets into the folder and sets Strength to 200? The server only calculates it, so he’d get 400 HP? How will it differentiate between the value changing by my own scripted training and someone else’s putting the value inside artificially? How to protect it exactly?