Player flings after teleporting to coordinates

I want to teleport player with character:MoveTo() to specific coordinates that always random X, static Y, random Z

  1. The player flings very high no matter what I do

  2. I tried to anchor player, teleport to coordinates above floor, coordinates of floor and coordinates under floor. Player always rockets to the sky

		elseif player:HasTag("Boss") then
			local BSpawn1 = workspace.Game_Mechanics.CurrentMap.BSpawn1
			local BSpawn2 = workspace.Game_Mechanics.CurrentMap.BSpawn2
			character:MoveTo(Spawns.Random(BSpawn1.Position.X, BSpawn1.Position.Z, 10, BSpawn2.Position.X, BSpawn2.Position.Z))
			character.HumanoidRootPart.CFrame *= CFrame.Angles(0, math.rad(180), 0)
		end

This part of code that runs then player is loaded.

local Spawns = {}

function Spawns.Random(X1, Z1, Y, X2, Z2)
	local answer = Vector3.new(math.random(X1, X2), Y, math.random(Z2, Z1))
	return answer
end

return Spawns

Module that I use in spawn code above (Spawn.Random)
Is this an engine problem or I just don’t understand something?

3 Likes

Try setting the players root velocity to zero for a set amount of time while also anchoring it. That could possibly help.

4 Likes

Can you provide a video please, I tried to replicate this but it didn’t fling me!

2 Likes

Sorry, can’t provide now, will be able later, in some hours. But player is teleported from higher position than the end coordinates.

1 Like

Try using :PivotTo(CFrame) instead of doing :MoveTo(Vector3)

So try replacing this code:

character:MoveTo(Spawns.Random(BSpawn1.Position.X, BSpawn1.Position.Z, 10, BSpawn2.Position.X, BSpawn2.Position.Z))
character.HumanoidRootPart.CFrame *= CFrame.Angles(0, math.rad(180), 0)

With this:

character:PivotTo(CFrame.new(Spawns.Random(BSpawn1.Position.X, BSpawn1.Position.Z, 10, BSpawn2.Position.X, BSpawn2.Position.Z)) * CFrame.Angles(0, math.rad(180), 0))

(Idk if that’s the issue but it may be)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.