Problem with a Script

I have a problem, the script doesn’t work:/ This is the error : ServerScriptService.Handler:3: attempt to index nil with ‘Parent’

game.Players.PlayerAdded:Connect(function(plr)
plr.Character.Parent = game.Workspace.InMenu
end)

Try doing a characterAdded event.

local InMenu = workspace.InMenu
game.Players.PlayerAdded:Connect(function(plr)
    local character = plr.Character or player.CharacterAdded:Wait() -- forgot about this for a second
    character.Parent = InMenu
end)

Wait for the character to exist either through WFC or a Character related event.

I don’t understand why you are parenting the character into an instance. Well, if you want the character: local character = player.Character or player.CharacterAdded:Wait() then set it’s parent into InMenu

You can also do:

repeat wait() until pr.Character -- Will wait until character is anything but nil or false
game.Players.PlayerAdded:Connect(function(plr)
      plr.CharacterAdded:Wait()
      wait()
      plr.Character.Parent = workspace.InMenu
end)
1 Like

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char.Character.Parent = workspace.InMenu
end)
end)

just realized someone already solved ;-;