so if I face the valve, the animation plays correctly, but if I face the side of the valve, the player won’t face the valve, but the direction he was looking at.
Video example:
Script which makes the player face that way:
function Hold(player)
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local hum = player.Character:WaitForChild("Humanoid")
local lookatp = script.Parent.Parent.LookAtPart
HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(lookatp.Position.X, lookatp.Position.Y, lookatp.Position.Z))
local valveAnim = hum.Animator:LoadAnimation(animation)
if playerHolding then return end
playerHolding = player
valveAnim:Play()
wait()
HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(lookatp.Position.X, lookatp.Position.Y, lookatp.Position.Z))
hum.AutoRotate = false
HRP.Position = Root.Position
HRP.Anchored = true
stopanim.Event:Connect(function(player)
valveAnim:Stop()
end)
repeat
Valve.CFrame = Valve.CFrame*CFrame.Angles(-0.1, 0, 0)
task.wait(1/40)
until not playerHolding
end