[Updated Again] Let me explain better. so if you click an image button, you teleport to a rp hub then you can click it again to teleport back to the last area in the rp that you were in.
This is the code:
function Teleport()
local GoTo = game.Workspace:WaitForChild("TheCastle")
if script.Parent.Value.Value == false then
script.Parent.Value.Value = true
p = script.Parent.Parent.Parent.Parent:WaitForChild("Head").CFrame
script.Parent.Parent.Parent.Parent:WaitForChild("Head").CFrame = GoTo.CFrame
else
script.Parent.Parent.Parent.Parent:WaitForChild("Head").CFrame = p
end
end
script.Parent.MouseButton1Down:connect(Teleport)
Yes, TheCastle is in workspace, yes script.Parent.Parent.Parent.Parent contains the head.
I even used
print(script.Parent.Parent.Parent.Parent)
to prove it
errors:
Nothing appears in the output box

14 comments
put print(script.Parent.Parent.Parent.Parent) right before line 6.
It prints "Player1"
put print(script.Parent.Parent.Parent:FindFirstChild("Head")) right before line 6.
well what do you know, it prints nil
meant script.Parent.Parent.Parent.Parent:FindFirstChild("Head") if that isn't what you wrote. if it is then try WaitForChild("Head")
So how would i find the head then
script.Parent.Parent.Parent.Parent:WaitForChild("Head")
It says argument 1 missing or nil
i replaced the FindFirstChild("Head") with WaitForChild("Head") and /
sorry about the typo, but when i replaced it, it says argument 1 missing or nil
what did you write
instead of p = script.Parent.Parent.Parent.Parent:FindFirstChild("Head"), i did p = script.Parent.Parent.Parent.Parent:WaitForChild("Head")
Oh wait nevermind, i found a typo
I updated the question to include my current script and answers