How to add custom property to a player?

in editor,i didt see any "player" object.so how to add a property to my player?

Screenshot_6
(you might be simply looking for ^ the player settings object and then you can add custom props or just change the player settings there, ignore the rest if that's all you needed)

If you want to make something custom on the scripting side. You can create a new script specific to the player, and setup as many props as you want for the player on that script or get the props on the player settings obj (as shown in the img above). On the lua side, you'll get the custom props in your code, and then on a player join event you can assign the custom prop(s) to the player using serverUserData or clientUserData so any script can access the specified props within that same network context, or you can just ignore using those and just keep the prop info in that one script, it really depends on what you are trying to achieve.

If you are dealing with things like a players score, xp, currency, then you could use SetResource, AddResource, and GetResource if you are looking for a more friendly function call that works out of the box without having to deal with a lua table (which is all serverUserData & clientUserData are, both are just a table that you can access across any scripts within that specific network context)

1 Like