I am making a script that teleports the player from the spawn area to the actual game but for some reason it doesn't work and it gives me this error: Workspace.SpawnTeleport.SpawnTp.Script:3: attempt to index local 'Pos' (a nil value)
This is the script:
function Touch(hit) local Pos = script.Parent.Parent:findFirstChild(script.Parent.Parent.SpawnTp2) hit.Parent:moveTo(Pos.Position) wait() end script.Parent.Touched:connect(Touch)
The script is located inside of the part that I want the player to touch to be teleported and that part along with the part I want the player to be teleported to are in a group model.
You don't want to use moveTo for teleportation, you just want to get the hit.Parent to the position instantly, so the solution is a lot simpler than what you've got there
local part = script.Parent.Parent --easier than typing it over and over again function Touch(hit) local Pos = part.SpawnTp2 --you don't need to find first child if you already know what its called hit.Parent.CFrame = Pos.CFrame end script.Parent.Touched:Connect(Touch)--capitalize connect
And a side note, capitalization matters
If this answers your question, then mark it as the accepted answer.