Is it possible to change a Character's orientation with a ServicerScriptService script?

Hi, if you seen my last post a couple days ago, I’m trying to make a game kinda like Mortal Kombat or Streetfighter. Right now I was able to make a script a way to copy the two characters, but the problem is is the 2nd player isn’t facing the 1st player.

(This script is in ServerScriptService if you didn’t know)

local player1 = false

local player2 = false

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		task.wait()
		char.Archivable = true
		if player1 == false then
			player1 = true
			local clonedChar = char:Clone()
			clonedChar.Humanoid.DisplayName =  "Player 1"
			clonedChar.Name = "Player 1"
			clonedChar.HumanoidRootPart.CFrame = workspace.PlayerOneStand.CFrame
			clonedChar.Parent = workspace
		elseif player2 == false and player1 == true then
			player2 = true
			local clonedChar = char:Clone()
			clonedChar.Humanoid.DisplayName = "Player 2"
			clonedChar.Name = "Player 2"
			clonedChar.HumanoidRootPart.CFrame = workspace.PlayerTwoStand.CFrame	
			clonedChar.Parent = workspace
		else
			char.Archivable = false
		end
	end)
end)

5 Likes

clonedChar:SetPrimaryPartCFrame(clonedChar.PrimaryPart.CFrame + CFrame.Angles(0,math.pi,0))

2 Likes

Use PivotTo() instead of SetPrimaryPartCFrame(); it’s deprecated.

2 Likes

neither of those worked

there is an error here

clonedChar:PivotTo(clonedChar.PrimaryPart.CFrame + CFrame.Angles(0,math.pi,0))

And the Second player does not load into the game

2 Likes

Try this. You have to wait until both characters are fully loaded before changing their orientation.

character1:PivotTo(CFrame.new(character1.PrimaryPart.Position, character2.PrimaryPart.Position))

character2:PivotTo(CFrame.new(character2.PrimaryPart.Position, character1.PrimaryPart.Position))
1 Like

Sorry for the really late reply, so I tried it. And Player 2 isn’t facing Player 1 still. If this helps, the Orientation Y is 177.049

You should try doing this on the client.

I can’t or else the rest of the script won’t work

Nvm, I just realized these are not player models so it’s fine.

1 Like

Turn PlayerTwoStand 180 degrees on the y axis.

1 Like

after setting each players cframe to each stand use CFrame.lookAt() and inside the brackets put the other’s player position

also i just realized that the simplest solution would be to rotate the playerstandtwo so it faces playerstandone

Umm…that’s what I’m asking how to do, though I said orientation, I was also meaning any type of rotation within the script. Sorry if I wasn’t clear!

1 Like

Click the part and hold the ring that goes around the part horizontally until the part is rotated 180 degrees.

after teleporting the player change player’s 2 humanoid root part angle using this

CFrame.Angles(math.rad(180), 0, 0)

(keep in mind the numbers inside the brackets might need changing

2 Likes

Was this what you meant? Because I did this

clonedChar.HumanoidRootPart.CFrame = CFrame.Angles(math.rad(10), 0 , 0)

and this happened…

(It went on the same side as Player 1 instead of the side for Player 2)

(also when it was set at 180 it was upside down)

clonedChar.HumanoidRootPart.CFrame = workspace.PlayerTwoStand.CFrame * CFrame.Angles(0, math.pi, 0)
3 Likes

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