I want a pretty simple teleporter. but I have an issue like I said in the title of this post if you touched the part with the touched event and then you touch a character with a humanoid the teleporter event fires on the player that touched it before.
here is a video with print statements:
External Mediahere is the code:
local teleporter1 = script.Parent.Teleporter2
local Teleporter2 = script.Parent.Teleporter1
local Realm = workspace.Map:WaitForChild("BingusRealm")
local Players = Realm.Players
local funcs = {}
local List = {}
teleporter1.Touched:Connect(function(hit)
local Char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(Char)
print(Char)
if player then
if not table.find(List,player) then
table.insert(List,player)
Char.HumanoidRootPart.CFrame = Teleporter2.CFrame * CFrame.new(0,2,0)
local PlId = Instance.new("BoolValue")
PlId.Name = player.UserId
PlId.Parent = Players
local c
c = Char.Humanoid.Died:Connect(function()
c:Disconnect()
funcs[player.UserId] = nil
end)
funcs[player.UserId] = c
wait(3)
table.remove(List,table.find(List,player))
end
end
end)
Teleporter2.Touched:Connect(function(hit)
local Char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(Char)
print(Char)
if player then
if not table.find(List,player) then
table.insert(List,player)
Char.HumanoidRootPart.CFrame = teleporter1.CFrame * CFrame.new(0,2,0)
Players:FindFirstChild(player.UserId):Destroy()
funcs[player.UserId]:Disconnect()
funcs[player.UserId] = nil
wait(3)
table.remove(List,table.find(List,player))
end
end
end)
if anyone can help me I’d really appreciate it.