Character Not Spawning to Spawn Point When Join?
Asked by
6 years ago Edited 6 years ago
When the player joins the game, the character is supposed to spawn to a specific spawn according to their player number and the spawn name. For some reason it doesn't work. Can someone help?
(Script is inside a normal script in ServerScriptStorage
)
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | local playernum = Instance.new( "StringValue" ) |
03 | playernum.Parent = player |
04 | playernum.Name = "Player" |
05 | local players = game.Players:GetPlayers() |
06 | for _, v in pairs (players) do |
07 | playernum.Value = "Player" ..#players |
09 | player.CharacterAdded:Connect( function (char) |
10 | local humanoid = char:WaitForChild( "Humanoid" ) |
11 | local spawnlocations = game.Workspace:WaitForChild( "BloxopolyBoard" ):WaitForChild( "SpawnLocations" ):GetChildren() |
12 | local spawnfolder = workspace:WaitForChild( "BloxopolyBoard" ):WaitForChild( "SpawnLocations" ) |
14 | for i, v in pairs (spawnlocations) do |
15 | if playernum.Value = = v.Name then |
16 | print (playernum.Value) |
17 | local torso = humanoid.Parent:FindFirstChild( "Torso" ) |
18 | torso.CFrame = CFrame.new(spawnfolder:FindFirstChild(playernum.Value).Position) + Vector 3. new( 0 , 3 , 0 ) |
It just stops working up until the print(), but I get no errors.