I’m making a Speed Run game in which you finish a level and move on to the next one by touching a portal. Right now you face whatever direction you were facing when you entered, but I want players to be orientated to face forward so they don’t have to turn and figure out where they are.
I tried doing this by changing HumanoidRootPart’s orientation, as well as torso but neither worked.
I tried replacing where I changed the rootpart position with that bottom one but it still didn’t rotate my character in the direction it was supposed to
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
hit.Parent.HumanoidRootPart.Position = game.Workspace.Checkpoints.Checkpoint3.Position + Vector3.new(0,5)
end
end)
Alright, there are a few things that I would fix about this.
Use the HumanoidRootPart’s CFrame as Position can sometimes break the character
You are just adding to the Position when you do +Vector3.new(0,5) and Vector3.new() uses 3 paramaters not just 2
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.Checkpoints.Checkpoint3.Position, Vector3.new(0,5,0))
end
end)
local goal = Vector3.new(x, y, z) --Replace these variables (orientation)
local goalposition = Vector3.new(x, y, z) --Replace these too (position)
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild(“HumanoidRootPart”) then
local hp = hit.Parent.HumanoidRootPart
hp.CFrame = CFrame.new(goalposition.X, goalposition.Y,goalposition.Z) * CFrame.Angles(math.rad(goal.X), math.rad(goal.Y), math.rad(goal.Z))
end
end
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
hit.Parent.HumanoidRootPart.CFrame = game.Workspace.Checkpoints.Checkpoint3.CFrame * CFrame.Angles(0,math.rad(From 0 to 360),0) + Vector3.new(0,5,0)
end
end)