I wanted make a part when touched it teleports to a different place. But here’s a problem, when the part is touched too many times, the game freezes and crash. I tried to find a way to stop it by making any player who touches it can have the affect for one time. But, I don’t know how to do it myself.
local Main = game.Workspace.Maps.TeleportMagic1
local Floors = game.Workspace.Maps.Floor1
local Place = game.Workspace.Maps.Walls1
local Location = game.Workspace.Maps.NameTag1.BillboardGui.PlayerCounter1
local PlaceID = ----
local Teleport = game:GetService("TeleportService")
local JumpServ = script.Parent.Parent.JumpService.Jump1
while true do
wait(0.1)
if Location.Text == "7/10" then
script.Parent.Parent.VoteAmount1.Disabled = true
Location.Text = "Teleporting"
for i, v in pairs(Place:GetChildren()) do
v.CanCollide = true
end
wait(0.1)
Main.Touched:Connect(function(hit) -- Detect the player, teleports to the game.
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
Teleport:Teleport(PlaceID, Player)
if Main.Touched:Connect() then
end
end
end)
JumpServ.Disabled = false
Floors.Velocity = Vector3.new(0,75,0)
wait(10)
JumpServ.Disabled = true
Floors.Velocity = Vector3.new(0,0,0)
script.Parent.Parent.VoteAmount1.Disabled = false
for i, v in pairs(Place:GetChildren()) do
v.CanCollide = false
end
end
end