I am trying to edit this teleporter script to teleport the player that touches it to a part with the same name as their team. But I am having trouble with it. When I touch it I get an error reading “Attempted to index nil with ‘Locked’” on line 5. I tried searching solutions or what this means but I can’t seem to solve it or understand it.
function Touch (hit)
local Plr = hit.Parent.Name
local Teleport = game.Players[Plr].Team
local Pos = script.Parent.Parent:FindFirstChild(Teleport)
if script.Parent.Locked == false and script.Parent.Parent : FindFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:FindFirstChild(Teleport).Locked=true
hit.parent:moveTo(Pos.Position) wait(1)script.Parent.Locked = false script.Parent.Parent:FindFirstChild(Teleport).Locked = false
end
end
script.Parent.Touched:connect(Touch)
Thank you for any help in advance