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

Teleport to Place Gui Button?

I was editing the cutscene editor's main script for the skip button and I am not really sure why my script wont work. Im trying to allow the local player to click on the button and have them teleport to my second place.

repeat wait () until script.Parent.Cutscene.Value ~= nil
script.Parent.Skip.Visible = true

function onClicked(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        game:GetService("TeleportService"):Teleport(1519449994, player)
	script.Parent:Destroy()
    end
end


script.Parent.Skip.MouseButton1Down:connect(onClicked)

1 answer

MouseButton1Down doesn't return "hit", it only returns the X&Y values of the player's mouse:(https://wiki.roblox.com/index.php?title=API:Class/GuiButton/MouseButton1Down).

Instead, you can just define your player as the LocalPlayer, assuming your script is a LocalScript:

repeat wait () until script.Parent.Cutscene.Value ~= nil
script.Parent.Skip.Visible = true

function onClicked(hit)
    local player = game.Players.LocalPlayer
    if player then
        game:GetService("TeleportService"):Teleport(1519449994, player)
    script.Parent:Destroy()
    end
end


script.Parent.Skip.MouseButton1Down:connect(onClicked)

1 comment

0

MouseButton1Down doesn't return anything

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