this simple script is not working
game.Players.PlayerAdded:Connect(function(plr)
local spawnpoints = game.Workspace.Lobby.SpawnPoints:GetChildren()
local spawnamount = #game.Workspace.Lobby.SpawnPoints:GetChildren()
local char = plr.Character
char:SetPrimaryPartCFrame(spawnpoints[math.random(1,spawnamount)].CFrame)
end)
and its supposed to tp a player to a random spawnpoint heres the error i am getting:
ServerScriptService.Script:5: attempt to index nil with 'SetPrimaryPartCFrame'
Edit: fixed i just added a wait(1) after the first line i guess the character wasnt existing yet

1 comment
U also could of done WaitForChild("Humanoid")