So I am trying to release a Halloween update on my group. For some reason when I go in-game and go onto a teleport part the game hard crashes making my screen go white as soon as I go onto the game. If I use admin commands and do :place me 12345689 it teleports me to the game without it crashing. Could anyone tell me why this is happening and how to fix it because this issue is really big…
Thanks! ps I would post this in bugs but it won’t let me!
@ImTheBuildGuy I checked that, and I even redid my code that doesn’t help.
local TeleportService = game:GetService("TeleportService")
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TeleportService:Teleport(5350231783, player)
end
end
script.Parent.Touched:connect(onTouched)
I tried looking on the group games for malicious scripts in models and there’s none…?
I once made a brick which teleports you to a place when touched; it looked like this:
local TPService = game:GetService("TeleportService")
local PlaceId = 1234567890
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
TPService:Teleport(PlaceId, plr)
end
end)
Mine works just fine, it might be something in the other place is making you crash
It isn’t the other places. There’s a game on my group I haven’t updated in nearly 2 months and it also hard crashes now. This started happening after the most recent Roblox update…
It might be that the players touching the part that many times it’s trying to spam teleport them causing lag. Maybe add some sort of check to see if they’ve already touched it. As I read someone say above, add a debounce. For example, giving them 20 seconds to teleport before somebody else can.
local TeleportService = game:GetService("TeleportService")
local debounce = false
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
debounce = true
TeleportService:Teleport(5350231783, player)
wait(20)
debounce = false
end
end
script.Parent.Touched:connect(onTouched)
Are you testing it in roblox studios or in game?
If you’re testing it in roblox it wouldn’t work, if in game it should.
Note, if it doesn’t work it’s probaly because you didn’t save the draft of the script.
That should be the error if you try it in roblox studio, next time I suggest checking the errors.
Btw, please close the topic if you found your solution.
It can be script.Parent.Touched:connect(onTouched). I personally use script.Parent.Touched:Connect(onTouched), because it does look better and it is not deprecated.