Hi, i’m currently working on a robbery type game and the main script is broken. Here is an image:
I saw the error and I got really confused. If you have a fix to this situation, thank you.
Hi, i’m currently working on a robbery type game and the main script is broken. Here is an image:
Try player.leaderstats. ‘leaderstats’ is the only valid name for a stats folder Roblox takes to display its values automatically in the playerlist.
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
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.