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

How to you use click to use TeleportService? [SOLVED]

Asked by 9 years ago

How to you use click to use TeleportService? for example: ClickDetector and you teleport to a place

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
    game:GetService("TeleportService"):TeleportToSpawnByName(152842348, "SpawnLocation", player)
    end
end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by 9 years ago

Take a look at ClickDetector. Instead of using "script.Parent.Touched", which is using the Touched event, you want the MouseClick event:

function onClick(player)
    game:GetService("TeleportService"):TeleportToSpawnByName(152842348, "SpawnLocation", player)
end
script.Parent.MouseClick:connect(onClick)
0
Thanks! Carlardar 5 — 9y
0
You're welcome. Please mark this as the answer if it helped. chess123mate 5873 — 9y
Ad

Answer this question