Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem in Teleport Gui script?

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago

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.

Ad

Answer this question