I'm creating a script that makes a value for each specific player when they join the game.
(I've tried to use plr and it hasent worked)
function onPlayerAdded(plr) local plruser = plr defaultvalue = script.Default mv = defaultvalue:Clone() mv.Name = ""..plruser mv.Value = 999 end game.Players.PlayerAdded:connect(onPlayerAdded)
Error: Workspace.Script:8: attempt to concatenate local 'plruser' (a userdata value)
you are trying to assign the name to the player object ,Lua_errors
Some of the problems
function onPlayerAdded(plr) local plruser = plr -- you have the variable plr so you don't need another one defaultvalue = script.Default -- if you are only using this once then you do not need to create a variable -- you make a clone but do not set its parent so it will be removed after the code block ends mv = defaultvalue:Clone() -- never use implicitly conversions as they are very bad practice as you have no control over how this is done mv.Name = ""..plruser -- since plruser is the player object it cannot be converted this way mv.Value = 999 end game.Players.PlayerAdded:connect(onPlayerAdded)
The Solution:-
function onPlayerAdded(plr) local mv = script.Default:Clone() -- I would use server storage but I don't know why you need this done this way mv.Name = plr.Name -- the name of the player mv.Value = 999 mv.Parent = -- some parent end game.Players.PlayerAdded:connect(onPlayerAdded)
Hope this helps