Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problem in Teleport Gui script?

First Im gonna tell you whats suppose to happen I click a button then a GUI Pops Up and ask you if you want to be teleported If you click yes it will if no it will close but when i clicked yes it dosent teleport please assist me

Here's the script i used

print("Teleport!")

button = script.Parent
window = script.Parent.Parent

function onClicked(GUI)
	onCLicked.Parent.Torso.CFrame = CFrame.new(Vector3.new( -737.12, -267.22, 391.47)) --change the zeros to where you want the player to end up.

end
script.Parent.MouseButton1Click:connect(onClicked)

1 answer

✓ Accepted answer

There are a few problems with this code For example, the variable onCLicked is never defined. There is onClicked, but that's a function, not a component of the Character. If you put this in a LocalScript, then we can reference LocalPlayer.

print("Teleport!")

button = script.Parent
window = script.Parent.Parent
local plr = game.Players.LocalPlayer;
local char = plr.Character or plr.CharacterAdded:wait();

function onClicked(GUI)
    char.Torso.CFrame = CFrame.new(Vector3.new( -737.12, -267.22, 391.47))
end
script.Parent.MouseButton1Click:connect(onClicked)

If this doesn't work, post a comment to this reply.

This discussion is preserved as it was. New answers, comments, and votes are closed.