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

I do not understand this Teleport Script?

Asked by 10 years ago

I want to make it so if someone clicks a part they get teleported to a game but my script is not working and I would appreciate some help.

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

1 answer

Log in to vote
2
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

Some events get the information you need like with mouse click, it will tell you what player clicked the brick.

script.Parent.ClickDetector.MouseClick:connect(function(player) --You want to have the script identify the player here.
    wait(2)
    -- Just completely remove this line, it was set up for a Touched event.
    if player then --Good, keeping the script from breaking.
        game:GetService("TeleportService"):Teleport(165643174, player)
    end
end)

I haven't tested this, nor have I really test Teleport Service, but I think this will work.

0
Thankyou for the help. It works frostmario2 30 — 10y
Ad

Answer this question