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

Teleporting to another game when brick is clicked?

I have a part and when I click it it does not tp me to the game id. (I have a clickdetector in the part)

script.Parent.ClickDetector.MouseClick:connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        game:GetService("TeleportService"):Teleport(361116138, player)
    end
end)

1 answer

✓ Accepted answer

You don't need to use GetPlayerFromCharacter since the Parameter for MouseClick event already returns the Player for you!

script.Parent.ClickDetector.MouseClick:connect(function(hit)
    if hit then
        game:GetService("TeleportService"):Teleport(361116138, hit)
    end
end)

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