Instance not parenting to player

This very basic script is not working for some reason.

	local new ="StringValue")
	new.Parent = plr
	new.Name = "discordID"

Help would be highly appreciated.

I have just found out that it only works in roblox but not in studio. How do I resolve this?

Put a wait or Task.wait there because it can load longer.
I give 1-3 seconds. I do this every time the player joins.

Have you tried?

local players = game:GetService("Players")

local function onPlayerAdded(plr: Player)
    local new ="StringValue")
    new.Name = "discordID" 
    -- make sure you're not collecting Discord ids from *every* user or that'll 
    -- be the quickest way to have your game (and potentially, your account)
    -- moderated
	new.Parent = plr

-- Connect the signal to the function

for _, player in players:GetPlayers() do
   -- This loops through all players in the game (in case the event didn't fire)
   onPlayerAdded(player) -- Calls the PlayerAdded function for the current player

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.