The Camera And The Character Face Different Directions

Hello Devs!
In my game when the characters spawn they face one direction while the player faces another direction. I earlier had a problem where the character was facing towards an unintended direction after i fixed that the character started spawning in the correct direction but the camera stated facing towards the player.


The script that i use to rotate the player is also the leader stats script of my game which is given below:

local checkpoints = workspace:WaitForChild("Checkpoints")
game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr

	local v = Instance.new("IntValue")
	v.Name = "Stage"
	v.Value = 1
	v.Parent = leaderstats

	plr.CharacterAdded:Connect(function(char)
		local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
		char:MoveTo(checkpoints[v.Value].Position)
		task.wait()
		HumanoidRootPart.CFrame = checkpoints[v.Value].CFrame + Vector3.new(0, 3.5, 0)

		HumanoidRootPart.Touched:Connect(function(hit)
			if hit.Parent == checkpoints then
				if tonumber(hit.Name) == v.Value +1 then
					v.Value = v.Value +1
				end
			end
		end)

	end)
end)

Thankyou For Reading

2 Likes

If you’d like to make the character face in a certain direction you can make use of CFrame.Angles.

My question is: Is this a really big issue for you? I don’t think it seems like too much of an issue personally but try CFrame.Angles to help you.

1 Like

Thanks for replying!
Actually it is not a really big issue but it is one of the little details of the game that could be frustrating cause if like in the first picture the camera faces towards the player and the player presses w so he will go front with respect to the camera (backwards).
Also should I add Cframe angles to both the character and the camera or just to the camera?

1 Like

I don’t think you need the camera orientation script, if I remember correctly you can just orient the spawnlocation facing where you want it to and the character / camera will spawn facing the same direction in that direction

Yes I tried that already but it apparently all the spawn points spawn facing forward (with respect to terrain).
Do you know of a solution for this will be really helpful.
Thank you for responding :cowboy_hat_face:

Just to the character, you can do it on the HumanoidRootPart to rotate it and it’ll rotate the whole character!

2 Likes