Teleporting Flinging Player

Hey Devs,

I am trying to teleport the player to a certain location whenever they touch a part. The player does teleport, but more times than not, they are flung onto the ground, like so:

https://gyazo.com/4474a6619ba6e88cd52618737dcd0ea9

The teleport part is CanCollide = false.

Here is the code that I am currently using the teleport the player

local part = script.Parent

local folder = part.Parent

local tp = folder.Teleport

local function shopOpen(otherPart)
	local player = game.Players:FindFirstChild(otherPart.Parent.Name)
	if player then

		player.Character.PrimaryPart.CFrame = (tp.CFrame * CFrame.Angles(0,math.rad(-90),0))
		
	end
end

part.Touched:Connect(shopOpen)

EDIT:

The script is a Server Script, if that makes a difference in teleporting.

1 Like

You should just say player.Character.HumanoidRootPart.CFrame = tp.CFrame.

Edit: Not sure if you want something to happen to the player but this is how I always do it when I teleport the player.

2 Likes

This still flinging the player onto the ground.

And I believe that PrimaryPart is the same as HRP; but Primary part works for both R6 and R15

Are you sure the player isn’t being welded to the baseplate? Perhaps you should consider looking for welds within the teleport part through the explorer.

1 Like

I did not think about that, but no that does not seem to be the issue.

There are no Welds within either of the parts that handle teleporting.

@Rynappel

Works fine for me in studio, do you have welds in the teleport part? Try removing them and see if it works.

Try adding debounce, maybe the player is being teleported too many times and it trips over. I honestly don’t know why it isn’t working for you.

local part = script.Parent
local folder = part.Parent
local tp = folder.Teleport

local debounce = true

local function shopOpen(otherPart)
	if debounce == true then 
		debounce = false
		local player = game.Players:FindFirstChild(otherPart.Parent.Name)
		if player then
			player.Character.PrimaryPart.CFrame = (tp.CFrame * CFrame.Angles(0,math.rad(-90),0))
		end
		wait(1)
		debounce = true
	end
end

part.Touched:Connect(shopOpen)
1 Like

I have a feeling you are kind of complicating the script.

You don’t have to add * CFrame.Angles(0,math.rad(-90),0). All you really have to do is equal the CFrame of the player’s primary part to the tp part.

local a = workspace.A
local b = workspace.B

a.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.HumanoidRootPart.CFrame = b.CFrame
	end
end)

Heres a simple script without any extra things that works fine.

1 Like

I added a debounce and tested it, and the player is still thrown on the ground.

I then changed the players CFrame to equal just the Parts CFrame without the rotation, and it is still not working.

@Rynappel

Do you have the part that the player teleports to on the ground or raised into the air?

On a side note, I don’t think this is causing the issue, but I also have a Particle Emitter in the part that triggers the teleporting, so could you try adding one yours?

This is what I’ve done, when i add a particle emmiter into the touch part nothing different happends.

image
I did this and got the same results

Edit: Are you absolutely sure that the tp part is can collide false?

@Rynappel

The only difference that I can think of now is that my floor is Terrain instead of the Baseplate. But like with the particle emitter, I don’t think this would be cause the issue.

If you are not using R15 than that could be another difference?

It seems like the player is rotating as soon as they are teleporting, and that causes it flip to the ground for a few second.

My teleport part is directly behind the part that triggers the teleporting, and whenever the teleport actually works successfully, they are facing the opposite direction of the trigger part.

Now the only thing I do that gets your result is that the teleport to part is cancollide true. Please make sure that the part that the player teleports to is cancollide false.

The only thing I could think of is some script is setting the CanCollide to true. When you spawn in, click the select tool and select the teleport part to see if CanCollide is true

@HonestJar

Sorry for the delayed response but I did double check to see if the part was CanCollide false, and it is.

So I really don’t understand how we are getting different results from the same code.

1 Like

Perhaps, try adding a debounce? I think it might because it is teleporting the player a lot in a short period of time.

1 Like

Try using this

local target = CFrame.new(tp.Position)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if Player.Character and player.Character:FindFirstChild("Head") then
	Player.Character.Head.CFrame = target + Vector3.new(0, i * 5, 0)
end		

Let me know if it works

1 Like

I’d read all the answers and your issue should be fixed by now, cause everyone said good ideas. Would be good to see your place file. Cause this sounds very weird. I always take the HumanoidRootPart.CFrame and change it to any position and nothing goes weird. Why u dont share a file using ur scripts and let us experience the issue? Just a suggestion

1 Like

I’m not sure but maybe try looping through every bodypart and setting their velocity to

Vector3.new(0,0,0)

1 Like

@LegendaryElix3r

I do have a debounce within the script.

Here is the most updated version of the Code that I am using:

Summary
local part = script.Parent

local folder = part.Parent

local tp = folder.Teleport

local debounce = true

local function shopOpen(otherPart)
	if debounce then
		debounce = false
		
		local player = game.Players:FindFirstChild(otherPart.Parent.Name)
		if player then

			player.Character.PrimaryPart.CFrame = tp.CFrame


		end
		
		wait(1)
		debounce = true
	end
end

part.Touched:Connect(shopOpen)

@jaipack17

I just tried your code, but it results in the same issue. It seems that the player is teleported sideways to the part.

@Dev_Peashie

Here is a file that is using the exact parts and script that I am using within my main place. It is all in the exact order as the original; and I am still getting this issue within the test file that I am providing.

TeleportingIssue.rbxl (26.1 KB)

I just figured out that the issue was rooted in the fact that the part that the player teleports to wasn’t rotated with the top being pointed upward.

Because of this, every time I tested it, the player was being rotated sideways which was why it was being flung onto the ground.

Really simple fix for an issue that has had be stumped for a while haha.

1 Like