[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
It looks like this script is running locally, which means the script is running before some of the things in the character have loaded. On line 6, WaitForChild is used to make sure that the head exists before continuing, but line 9 does not. Use WaitForChild instead of FindFirstChild on line 9.
Here's a nicer way to write it:
local head,p=script.Parent.Parent.Parent.Parent:WaitForChild("Head") local GoTo=workspace.TheCastle script.Parent.MouseButton1Down:connect(function() if script.Parent.Value.Value then head.CFrame=p else p=head.CFrame head.CFrame=GoTo.CFrame end script.Parent.Value.Value=not script.Parent.Value.Value end)
To answer your question, there is a YouTube channel of roblox tutorials with teleporting pads for scripting. The channel if SharQuishuhh_RBLX.