I am trying to create a script for when A player joins they teleport to a random brick. When I click play to test I get this messageWorkspace.Teleport To Map:6: attempt to index field 'HumanoidRootPart' (a nil value) I don't know what to do and would like some help. Thank you!
Here's My Code
game.Players.PlayerAdded:Connect(function(plyr)
if game.Players.PlayerAdded == 2 or 3 or 4 then
local Pos1 = game.Workspace.Spawn.Pos1
local Pos2 = game.Workspace.Spawn.Pos2
wait(2)
game.Players.Name.HumanoidRootPart.CFrame = CFrame.new((Vector3.new(math.random(1,2))))
end
end)
I don't understand what is wrong

4 comments
What are the hashtags on game for?
#game.Players:GetPlayers() gets the total number of players in the server.
I Wrote what you did and It says Character is a nil value
Oops, I did ".Caracter.:", it should be ".Character:". Sorry. Also, this is because the character wasn't added yet. I edited my post, please check.