I have watched many youtube tutorials, they all work but for some reason, none of them work on my game. If I use a different game, the teleport pads will work but not on the game I use. The script is :
local TeleportService = game:GetService(“TeleportService”)
local gameID = 6105017665 --Remove this and put the second Game ID –
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TeleportService:Teleport(gameID, player)
end
end
script.Parent.Touched:Connect(onTouched)
Also, the game it doesnt work on is: Subway - Roblox
Can you please tell me why it doesnt work.
It is regular. I am trying to see why it doesn’t work, I could have some scripts that dont allow it. But I don’t know I am not a scripter, this is really frustrating.
local TeleportService = game:GetService(“TeleportService”)
local gameID = 6105017665 --Remove this and put the second Game ID –
function onTouched(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print("1")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
print("2")
TeleportService:Teleport(gameID, player)
end
end
script.Parent.Touched:Connect(onTouched)
try this and tell me if it prints. (i updated the code a little bit)
Hmm. Can you try this code instead? It’s not for teleporting but im just trying to make sure Touched event is firing.
local debounce = false
local TeleportService = game:GetService("TeleportService")
local placeId = 6105017665
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if debounce == true then return end
debounce = true
print("Someone Touched to this part!")
TeleportService:Teleport(placeId, player)
wait(5)
debounce = false
end
end)
please tell me if it prints (i will edit this message if it prints)
I updated the code try it. If it won’t teleport maybe it’s an issue with roblox.
did it print though? also i forgot to delete an end so i updated the code again. Also don’t try on roblox studio. If it won’t work again I don’t know. Sorry.
This is what it printed exception while signaling: Cannot Teleport in the Roblox Studio.
it also said Someone touched this part! Didn’t see that when I typed that out.
for one the half visible has can collide off and would be invisible
local part1 = script.Parent
local part2 = script.Parent.Parent
local id -- id here
local function touched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
game:GetService('TeleportService'):Teleport(player,id)
end
end
part1.Touched:Connect(function(hit)
touched(hit)
end)
part2.Touched:Connect(function(hit)
touched(hit)
end)
as far as I can tell given the erros that you cannot telport in studio this should work, just place the id in the varible id
ignore the other stuff I use this place for testing random things so there are alot of random things around
though i still dont see anything wrong with any of the other code methods they should all work, just check that the place your teleporting to is actually a place in that games “universe” you can check this though the developer area of the website and see the places of that game