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

help with teleportation between places in same game?

Asked by 5 years ago
Edited 5 years ago

I keep getting this error when trying to teleport a player when they touch a part: exception while signaling: Cannot Teleport in the Roblox Studio

here is my code that is placed in a script.

local TeleportService = game:GetService("TeleportService")
local id = 2847968130 

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        TeleportService:Teleport(id, player)
    end
end

script.Parent.Touched:connect(onTouched)

I have tried testing using servers pressing F7 but I still get this error. Please help!

0
Try it outside studio? Isaque232 171 — 5y
0
i tried running the game on roblox. does not seem to work either KaiserTheUltimateXD 5 — 5y
0
Make sure it's a server script BlackOrange3343 2676 — 5y
0
as in not a local script right? yea mine's in a normal script KaiserTheUltimateXD 5 — 5y
View all comments (9 more)
0
Dont use ":connect", its deprecated. (this won't fix the script, its just a good practice) cmgtotalyawesome 1418 — 5y
0
Any idea how i can fix the code? or maybe another code so that when part is touched teleports player to the other place? KaiserTheUltimateXD 5 — 5y
0
I kind of copied the example from developer.roblox.com so i'm really confused why it does not work KaiserTheUltimateXD 5 — 5y
0
This shouldn’t have much to do with your code. It’s stated in the Error itself, you cannot use the TeleportService in the Studio. I’m unsure why this is unsuccessful in-Game though. Ziffixture 6913 — 5y
0
OP is probably using *studio* servers. Launch a real server. Not in studio. User#24403 69 — 5y
0
What do you get in Roblox Player? Press F9 to see the logs Miniller 562 — 5y
0
Or /console in the Chat. Select the Server output Ziffixture 6913 — 5y
0
ah ok thanks! KaiserTheUltimateXD 5 — 5y
0
i solved it thanks everyone for your help KaiserTheUltimateXD 5 — 5y

Answer this question