I am new to scripting so sorry if its a stupid error. I am making a game where you have to fight with others with a sword and it gives me an error at the command: character:FindFirstChild("HumanoidRootPart").CFrameAvaliableSpawnPoints[1].CFrame This have to teleport you at the first spawnpoint found in a table. In the table are all the spawnpoints. I hope you understand what is my problem.
local AvaliableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
character:FindFirstChild("HumanoidRootPart").CFrame = AvaliableSpawnPoints[1].CFrame
table.remove(AvaliableSpawnPoints, 1)
local Sword = ServerStorage.Sword:Clone()
Sword.Parent = player.Backpack
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
if not player then
table.remove(plrs,i)
end
end
end
end

3 comments
Does this code runs right when the player spawns?
What error the output shows up?
attempt to index nil with 'CFrame'