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

Using the teleport service?

Asked by 4 years ago

Hello! I've inserted the following script in a part. It is a local script.

local TeleportService = game:GetService("TeleportService")
local Place = 4536115280

script.Parent.Touched:connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        TeleportService:Teleport(Place, player)
    end
end

When colliding with the part, you aren't moved to the game you should to. Any help?

0
Are you testing this in studio? I think you can't teleport in studio kisty1 111 — 4y
0
I wasn't teting in studio. Robloximario952 18 — 4y

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

You can't use Localscript with touched. Instead put it in a ServerScript Your using GetPlayerFromCharacter() anyway instead of game.Players.LocalPlayer.Character. So that means this goes in a ServerScript. As well when you put it in a ServerScript you cannot teleport in studio!

0
I changed it into a server script but anyways it stills not working. Robloximario952 18 — 4y
Ad

Answer this question