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

I do not understand this Teleport Script?

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

✓ Accepted answer

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.

1 comment

0

Thankyou for the help. It works

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