Why does my teleport script bug the player so badly

  1. What do you want to achieve? That the player by touching a block to another place in the place

  2. What is the issue? It bugs the player out

Video:

  1. What solutions have you tried so far? I’ve tried looking but I didn’t find anything

Teleport Script:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.HumanoidRootPart.CFrame = CFrame.new(18.911, 19.693, 102.484)
		wait()
	end
end)

Why am I doing wrong? Feel free to give feedback.

2 Likes

This may not fix it but I recommend instead of doing wait() you do task.wait()

Nope, That doesn’t fix the problem…

You dont have a debonce variable, Without a debonce variable your script will bug like that and teleport you multiple times.

https://developer.roblox.com/en-us/articles/Debounce
This article helped me understand what was wrong with my teleporting script before in the past when it glitched like that.

Nope, although he is now only being fired once (the teleport event) it is still bugging the player out.

EDIT: Maybe I am doing something wrong so here is the new code:

local RESET_SECONDS = 5
local isTouched = false 

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if not isTouched then
			isTouched = true 
			hit.Parent.HumanoidRootPart.CFrame = CFrame.new(18.911, 19.693, 102.484)
			print("Touched!")
			wait(RESET_SECONDS)
			isTouched = false
		end
	end
end)

Their is a function that will allow the cframe to teleport to a specific part, VA a script. Those functions are called ToWorldSpace or ToObjectSpace.

How would I use this function in this script?

Try this out.

Try this

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then
		hit.Parent.HumanoidRootPart.CFrame = partTwo.CFrame + partTwo.CFrame.LookVector * 4 -- Telepports the player a few studs away from the part, so it doesn't result in spam teleporting.
--also change the "partTwo" with the part that you want to teleport to.
	end
end)

I don’t get it it is still bugging the player out for some reason

EDIT: It looks like it teleports the player but the physical part spawns again in on a spawnpoint

robloxapp-20220117-1144576.wmv (1.3 MB)
This is me testing the script.

Do you have a kill function on the teleportation part?

-can you show me the whole script please

The player stays for some reason on the pad that teleports it and then the player respawns

What I gave was the entire script…

There might be a script interfering with the character getting teleported or changed

@TheGameGod_YT I rewatched the video multiple times and im sure the character disappears because of the ragdoll script

Could a checkpoint script interfer with it?

Checkpoint Script

local spawn = script.Parent
spawn.Touched:connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
		if not checkpointData then
			checkpointData = Instance.new("Model", game.ServerStorage)
			checkpointData.Name = "CheckpointData"
		end
		
		local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
		if not checkpoint then
			checkpoint = Instance.new("ObjectValue", checkpointData)
			checkpoint.Name = tostring(player.userId)
			
			player.CharacterAdded:connect(function(character)
				wait()
				character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
			end)
		end
		
		checkpoint.Value = spawn
	end
end)

Acvious could be correct. If a Debonce variable or a Vector displace meant does not work. Then the other solution might be another script interference.

No its definitely the radgoll script

Oh… Then I should read trough it I guess. Should I give that script to you maybe?