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:
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.
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.
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)
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.
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?
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
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
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
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)
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.