Player Facing Wrong Way

I have a script for when the player joins, they are moved to their zone, but face the wrong direction. I use :MoveTo, and I don’t believe it has an orientation property. I believe :PivotTo or CFrame.lookAt could be used, but I am not familiar with either of them. Right now, the player spawns in correctly and at the correct part, but they face to the left.

Here is the code:

local ServerScriptService = game:GetService("ServerScriptService")

local Manager = require(ServerScriptService.PlayerData.Manager)

local Zones = game:GetService("Workspace").Zones

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		task.wait()
		char:MoveTo(Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].Position)
		
		print("s")
		
		hum.Touched:Connect(function(hit)
			if tonumber(hit.Name) == player:WaitForChild("leaderstats"):WaitForChild("Zone").Value + 1 then
				Manager.IncreaseZone(player)
			end
		end)
	end)
end)

Please help. Thanks!

3 Likes

Have you got any screenshots/videos of this occurring? It’ll help identify the issue more clearly.

3 Likes

The player is turnt to the left, but they should be rotated another 90 degrees to the right, facing the wall.

2 Likes

Have you tried rotating the part 90 degrees?

2 Likes

Yes, it doesn’t fix the problem.

Is your game R6 ?
--------------------------------random characters to fill space

1 Like

Yes, it is. Is that the problem perhaps?

Not necessarily a problem but it could make this a bit more difficult as I’d planned to help you use :PivotTo

Ah, so are you still able to help?

Yes, I think you’ll need to add an offset to the character but that won’t be too difficult

Perfect, how would I go about it then?

I’m going to do a quick rundown on PivotTo because I’m pretty sure it’ll fix this issue

To use PivotTo you’ll want to start with the PrimaryPart of a model if you don’t have one set by default. The Primary part on R6 characters is the Head so we’ll need to add a vertical offset because I think it might get stuck otherwise.

You can do this with

char:PivotTo(Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].CFrame * CFrame.new(0,1.5,0))

It turns the player upside down initially, and since it’s on the head, it sometimes turns the right direction, but sometimes the wrong direction. Is there a way to do the rotation with CFrame?

Could you send a screenshot so I can see what’s happening?

Player is upside down.

As a quick test of something could you turn the 1.5 into a -1.5? I’m curious to see what it does.

Same thing happens; the player is stuck upside-down.

Okay, you could do * CFrame.angles(math.rad(180),0,0)) after the CFrame.new(0,1.5,0)

char:PivotTo(Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].CFrame * CFrame.new(0,-1.5,0) * CFrame.angles(math.rad(180),0,0))

Attempt to call a nil value.

Oh my bad, it’s CFrame.Angles I forgot to capitalize the “A”