Need help with teleportation parts

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:

Here is my Code:

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)
2 Likes

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!

1 Like

Wait, do you mean on the Dev Forum or in Roblox Studio?

Oh, I was wondering how you include videos in your posts on the Dev Forum. Sorry if I wasn’t specific enough in my original post

Whoops i’m sorry, I thought you were talking about the VideoFrames feature in Studio but it turns out I was wrong

1 Like

anyway it’s Upload/From the Web or From My Device

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?

Maybe is because the DB is still on true and you have to wait until it returns false(?) Not sure

Try Imgur, not sure if has also videos btw

1 Like

I don’t think that’s it, I waited at least 10 seconds and it still would not teleport my character.

Try differenciating the two DB
For Tele1 DB and for Tele2 DB2

1 Like

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.

1 Like

It actually caused the same problem as earlier, where whenever i tried to teleport back to Tele1, it would Immediately teleport me to Tele2 again.

Here’s my code

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

instead of position use cframe instead

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

I tried that, but it kept glitching my character. I could get out, but it was not ideal. Is there a way to fix this?

is the game r6 or r15? if you cant solve it then try this code

character:MoveTo(Part.Position, Part)
1 Like

Try this one:

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)