Change Orientation via Script doesn't work correctly

I change char’s orientation via script. When i click play it changes the orientation but it is not true orientation. When i click to “Current Server” view, i see true orientation but when view as a player it changes 90 degree. it doesn’t make sense.


Code:

local player = game.Players.LocalPlayer

RS:WaitForChild("StartGame").OnClientEvent:Connect(function()
	local char = player.Character or player.CharacterAdded:Wait()
	if true then
		char.HumanoidRootPart.CFrame = CFrame.new(-405.366, 0, -661.063)
		char.HumanoidRootPart.Orientation = Vector3.new(0,90,0)
	end
end)

1 Like

You’re doing it on the client so it doesn’t update to the server until they make an input I think

it fires when player clicked gui

It’s just replication, anything the client does won’t be seen by the server unless it’s the character. if you want them to all face that way then do it on the server since you’re already sending an event from it

Sorry, i am not good scripter. You are telling me change position via server? Am i able to access LocalPlayer’s HumanoidRootPart from server?

Yes, LocalPlayer is just an easier way of accessing a user’s client from their own game

I made script like that, but its same. The script location in Workspace.Part btw.

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
	intToE.Enabled = false
	RS.StartGame:FireClient(player)
	player.Character.HumanoidRootPart.Orientation = Vector3.new(0,90,0)
end)

Use PivotTo with a CFrame

Character:PivotTo(CFrame.new(Character:GetPivot().Position) * CFrame.Angles(0, math.rad(90), 0))

math.rad converts it from radians to degrees so you can use 0 - 360

Thank you, it works now!!!

1 Like

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