I made very cool epic script that teleports players to a second place, for my cool gun game, but instead of teleporting it crashes the game?
local TeleportService = game:GetService("TeleportService") local Place = (6018067182) script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then TeleportService:Teleport(Place, player) end end)
does anybody know why this happens?
Add a debounce; when you touch the brick you're sending multiple requests; therefore, crashing the game.
local TeleportService = game:GetService("TeleportService") local Place = (6018067182) local Debounce = false script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and not debounce then debounce = true TeleportService:Teleport(Place, player) wait(2.5) debounce = false end end)
hydrogyn