Every time I use the teleport service, I get a message coming up telling me an unexpected error occurred. I’ve put on fog, my part count is at 12443 (which I don’t think is too high, but I could be wrong) and I’ve tried to drop the graphics quality a bit.
What can I do to make the teleport service work? (that being said, it does seem to work for some others)
local TeleportService = game:GetService(“TeleportService”)
local placeID_1 = 5591520459
local placeID_2 = 5591520459
local function onPartTouch(otherPart)
local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
TeleportService:Teleport(5591520459, player)
end
end
script.Parent.Touched:Connect(onPartTouch)
This was the code I used (and it has sometimes worked, which makes it more mysterious). I must say at this point, I’m not a scripter by nature and I made this script with the help of the tutorial on Roblox’s Dev page. Once again, thanks for having a look!
Thanks so much! With your diagnosis, I tried to adapt the teleporter to counter less debounce (I’m not confident with my scripting skills). However, the problem persisted, so I tried to have a go at making my own script (this is the most advance thing I’ve ever done)
local partTouched = false
Workspace.part.Touched:Connect(function(hit)
if not partTouched then
partTouched = true
print("teleporting")
wait(1)
TeleportService:Teleport(5591520459, player)
partTouched = false
end
end)
Would this work, or is this just complete nonsense that I’ve made as a layman?
local Part = workspace.part
Part.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player ~= nil then
game:GetService("TeleportService"):Teleport(5591520459, Player)
end
end)
With cooldown:
local Part = workspace.part
local Cooldown = 1.5
local dbg = false
Part.Touched:Connect(function(hit)
if not dbg then
dbg = true
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player ~= nil then
game:GetService("TeleportService"):Teleport(5591520459, Player)
end
wait(Cooldown)
dbg = false
end
end)
Thanks so much for taking the time to code this. However, it didn’t seem to work properly, unless I wasn’t applying the script correctly (which in all honestly, is a good bet). Either way, I’m in your debt for taking your time to help me!
(update) So I tried it again with Kylerzong’s code and it worked, turns out I renamed the teleporter “teleporter” in the workspace which then caused problems. Seems to be okay again, for the time being atleast!
Thank you so much to everyone who helped me out today, hopefully I can improve my scripting abilities for the future, and if anyone has any building stuff, I may be able to return the favour!
It works only with my games. “Part” name is the key to what I was missing. For those who may have had trouble, Just switch the variable to the following:
local Part = workspace.part
to
local Part = game.Workspace.NameOfPartBeingHit