Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When Teleporting Two Players, Why Does This Script Not Make Them Stand Still and Face Each Other?

My game involves periodical battles. At the start of each one, two players are teleported to a ring a few dozen studs apart, and they are supposed to face one another and not be able to move for the first couple of seconds, then after a series of GUIs, be able to fight. I've tried anchoring the HumanoidRootPart, but it did something strange; it's a bit hard to explain, but the player was able to move around independent of its body, almost as if the player's "soul" had escaped from its body. The same thing occurred when I attempted to rotate the HumanoidRootPart in order to get the players to face each other.

This is quite bizarre to me. If I don't script anything about the HumanoidRootPart, they teleport just fine and are standing perfectly. They just aren't facing one another and are still able to walk around freely. How can I accomplish getting them to face each other and stand still while still preserving the idle animations that they make? (I'm using R15 for my game, by the way.)

This is my script.

function teleportToBattle(p1, p2)
	player1 = game.Players:FindFirstChild(p1.Name) --Finding the players.
	player2 = game.Players:FindFirstChild(p2.Name)
	if player1 and player2 then --If they are both present.
		player1.Character.HumanoidRootPart.Anchored = true --To keep the player still.
		player1.Character.UpperTorso.CFrame = CFrame.new(Vector3.new(-62, 8, -89.5)) --Teleports tthem to their respective position.
		player1.Character.HumanoidRootPart.Rotation = Vector3.new(0, -90, 0) --To make them face one another.
		player2.Character.HumanoidRootPart.Anchored = true
		player2.Character.UpperTorso.CFrame = CFrame.new(Vector3.new(-48, 8, -89.5))
		player2.Character.HumanoidRootPart.Rotation = Vector3.new(0, 90, 0)
	elseif player1 and not player2 then --In case one leaves or lags out.
		print("player1 wins")
	elseif player2 and not player1 then
		print("player2 wins")
	else
		print("no one wins")
	end
end

4 comments

0

Use UpperTorso instead of HumanoidRootPart

0

That killed the players.

0

PrimaryPart?

0

I just tried that, and when the players teleported, they were laying down and getting stuck in the floor instead of standing up.

1 answer

✓ Accepted answer

Lol. I love your description. I'm guessing you could have a part in the middle and do . This will make the player face the part.

player1.Character.Torso.CFrame = CFrame.new(player1.Character.Torso.CFrame.p,Vector3.new(CenterPart.CFrame.p.X,player1.Character.Torso.CFrame.p.Y,CenterPart.CFrame.p.Z))

This should work.

3 comments

0

Oh my goodness, it did work! I never would have thought of using a part to have the players face it! Thank you very much!

0

And I stopped them from moving by just setting their walkspeed to 0. Worked perfectly!

0

Lol. No problem though anchoring the torso could've worked too.

This discussion is preserved as it was. New answers, comments, and votes are closed.