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

How to face a Character a certain direction using Rotation?

Every time I run the Script, the character drops down while the HumanoidRootPart stays standing up. Is there a way to face the Character to the way I want it to face?

local players = game:GetService("Players")

function VolunteerAdded(Volunteer)
	print(Volunteer.Name.." Has Joined the OutCross Volunteer Program".."..Spawning in Pod")
	wait()
	script.Parent.HumanoidRootPart.CFrame = script.Parent.Parent.SpawnPod.SpawnPoint.CFrame
	wait()
	script.Parent.HumanoidRootPart.Rotation = Vector3.new(0,180,0)
end


players.PlayerAdded:connect(VolunteerAdded)

for _,Volunteer in pairs(players:GetPlayers()) do
     VolunteerAdded(Volunteer)
end

1 answer

✓ Accepted answer

How to Rotate Using CFrame

Since I don't know your setup, I can't tell you the exact numbers for the rotation. But I can provide some insight on how to rotate the Character.

You can rotate the Character by manipulating the HumanoidRootPart's CFrame. This involves using the CFrame.Angles constructor. Simply multiply the object's CFrame by a CFrame.Angles measurement to rotate the object.

Note: CFrame.Angles takes in radians, not studs. Arguments should be in math.rad form

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Code

function VolunteerAdded(Volunteer)
	print(Volunteer.Name.." Has Joined the OutCross Volunteer Program".."..Spawning in Pod")
	wait()
	local root = script.Parent.HumanoidRootPart
	local spawn = script.Parent.Parent.SpawnPod.SpawnPoint
	--Mess around with these numbers if it isn't rotated correctly
	root.CFrame = spawn.CFrame * CFrame.Angles(0,math.rad(180),0)
end

game.Players.PlayerAdded:connect(VolunteerAdded)
	for _,Volunteer in pairs(players:GetPlayers()) do
		VolunteerAdded(Volunteer)
	end
end)

2 comments

0

I't didn't work the way I want it to, Thanks though.

0

Wait! Nevermind It Worked!!! Thanks!

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