Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to face a Character a certain direction using Rotation?

Asked by 8 years ago

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

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 years ago

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)
0
I't didn't work the way I want it to, Thanks though. GeezuzFusion 200 — 8y
0
Wait! Nevermind It Worked!!! Thanks! GeezuzFusion 200 — 8y
Ad

Answer this question