I replaced stats with leaderstats. There is still an error.
I said specifically ‘leaderstats’, with lower-case L and S. Though, changing the values locally won’t work anyways as this must be done by the server.
Could you provide a screenshot of the explorer? Considering you tried to index player.Stats, I assume you have something corresponding to it parented to the player object?
You have to insert leaderstats into the player.
I don’t comprehend how you’re trying to index something which is never created locally nor server-side?
Though, you might have a look at the post I recently made for someone else regarding something quite similar for creating leaderstats:
[color=#FFC900] Considering you mentioned that you’re new to scripting then I recommend that you pay specific attention to how the explorer in the post is set up and which script type (script or localscript) is being used for the code provided in the post I referred to.[/color]
I’m new to scripting. How exactly do I do that?
You have to put the name of the folder inside the player or else it won’t work
Insert a script into ServerScriptService and create a new folder named leaderstats whenever a player joins.
For example:
game.Players.PlayerAdded:Connect(function(player) --getting the player who joined
local leaderstats = Instance.new("Folder", player) --making a new folder and inserting it into the player
leaderstats.Name = "leaderstats"
local cash = Instance.new("IntValue",leaderstats) --creating the cash value and inserting it into the folder
cash.Name = "Cash"
cash.Value = 500 --starting cash amount
end)
The post I referred to already provides a code example for this + the way you’re creating the Instances isn’t performant and is rather poor practice.
Will do, thanks for the tip
- Remember to set and change the values on the server and not locally with a LocalScript - make sure to have a look at Remote Functions and Events for this.
- I actually provided the correct code with no deprecated nor non-performant methods so my post is quite the more correct solution.
I just tried your method and the code didn’t work. @Enclamatic does work so i’m gonna use his method. But thank you for helping me though .
Then you implemented it incorrectly and didn’t set up the leaderstats folder on before-hand.
As I mentioned, pay attention to how I set it up.
Alright, so I did fix the issue. And your method is so much better. Thanks @rawbyte. No offense to @Enclamatic.
next time use a lua block instead of screenshots.