I am trying to make 2 pipes that, when touched, teleport the player to the other. Whenever I try to Teleport from the Sword Fighting Arena pipe to the Lobby pipe, it just immediately teleports me back to Sword Fighting Arena Pipe. Here is the video:
local Tele2 = script.Parent.SwordMarioPipe.Tele2
local DB = false
local Sword = game:GetService("ServerStorage"):FindFirstChild("Sword")
Tele1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and DB == false then
local character = hit.Parent
local HRP = character:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
HRP.Position = Tele2.Position
ClonedSword.Parent = player.Backpack
DB = true
wait(3)
DB = false
end
end)
Tele2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")and DB == false then
local character = hit.Parent
local HRP = character:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
HRP.Position = Tele1.Position
player.Backpack:FindFirstChild("Sword"):Destroy()
character:FindFirstChild("Sword"):Destroy()
DB = true
wait(3)
DB = false
end
end)```
Any Suggestions?
I followed SheaNorse's Tutorial on teleporters (with some alterations to include swords)
(BTW I'm still learning scripting and this is my first dev forum post. If I screwed up please tell me.)
I tried to watch the video but I was denied access to it
I recommend setting DB to true at the beginning to avoid undesired behaviour.
local Tele2 = script.Parent.SwordMarioPipe.Tele2
local DB = false
local Sword = game:GetService("ServerStorage"):FindFirstChild("Sword")
Tele1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and DB == false then
DB = true
local character = hit.Parent
local HRP = character:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
HRP.Position = Tele2.Position
ClonedSword.Parent = player.Backpack
wait(3)
DB = false
end
end)
Thank you so much! Found another problem, however, once I teleport back to Tele1, it will not let me teleport to Tele2. Also, how do you post a video? I tried, but it just gave me an error. Again, thank you!
I tried uploading from my device, but it just gave me an error message. I tried using google drive, but i guess people can’t view the file. Is there some widespread 3rd party way I don’t know about?
I am going to assume you also changed the DB in Tele2.
Does the output show any error?
Also, you WILL need to use different debounces for each teleport. DB1 for Tele1 and DB2 for Tele2 and use them separately.
local Tele2 = script.Parent.SwordMarioPipe.Tele2
local DB = false
local DB2 = false
local Sword = game:GetService("ServerStorage"):FindFirstChild("Sword")
Tele1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and DB == false then
local character = hit.Parent
local HRP = character:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
DB = true
HRP.Position = Tele2.Position
ClonedSword.Parent = player.Backpack
wait(3)
DB = false
end
end)
Tele2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")and DB2 == false then
local character = hit.Parent
local HRP = character:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
DB2 = true
HRP.Position = Tele1.Position
player.Backpack:FindFirstChild("Sword"):Destroy()
character:FindFirstChild("Sword"):Destroy()
wait(3)
DB2 = false
end
end)```
Wait a minute you are teleporting a player on another teleporter? Teleport him to another plate close to the teleporter and not on it, bc will trigger the script
local Tele2 = script.Parent.SwordMarioPipe.Tele2
local DB = false
local DB2 = false
local Sword = game:GetService("ServerStorage"):FindFirstChild("Sword")
Tele1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and DB == false then
local character = hit.Parent
local HRP = character:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
DB = true
HRP.CFrame = Tele2.CFrame
ClonedSword.Parent = player.Backpack
wait(3)
DB = false
end
end)
Tele2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")and DB2 == false then
local character = hit.Parent
local HRP = character:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
DB2 = true
HRP.CFrame = Tele1.CFrame
player.Backpack:FindFirstChild("Sword"):Destroy()
character:FindFirstChild("Sword"):Destroy()
wait(3)
DB2 = false
end
end)
i tried position it didnt work but when i tried cframe it worked
local Tele2 = script.Parent.SwordMarioPipe.Tele2
local DB = false
local Sword = game:GetService("ServerStorage"):FindFirstChild("Sword")
Tele1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and DB == false then
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
character:MoveTo(Tele2.Position)
ClonedSword.Parent = player.Backpack
DB = true
wait(3)
DB = false
end
end)
Tele2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")and DB == false then
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local ClonedSword = Sword:Clone()
character:MoveTo(Tele1.Position)
player.Backpack:FindFirstChild("Sword"):Destroy()
character:FindFirstChild("Sword"):Destroy()
DB = true
wait(3)
DB = false
end
end)