Movement works correctly but not the rotation?

Hello developers! I want to achieve a kind of jumpscare of a floating head for my game, but I don’t know how to make it to look at the player. The jumpscare is basically that when a player touches a part, the head spawns forward and quickly moves past the player with a Tween. The code looks like this:

player = game:GetService("Players").PlayerAdded:Wait()
local rp = game:GetService("ReplicatedStorage")
local Tweenservice = game:GetService("TweenService")
local sound = script.Parent.Laugh
local remote = game.ReplicatedStorage.TouchedPart
local db = false
local MonsterHead = script.Parent



remote.Event:Connect(function()
	if not db then
		if workspace.Curtains.ProximityPrompt.ObjectText == "Close" then
			db = true
			
			local newPos = player.Character.Head.CFrame * CFrame.new(0,0,10)
			MonsterHead.CFrame = player.Character.Head.CFrame * CFrame.new(0,0,-10) 
			

			local info = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
			local tween = Tweenservice:Create(script.Parent,info, {CFrame = newPos})
			tween:Play()
			sound:Play()
			wait(0.8)
			script.Parent.Parent = rp
		end
		
	end
end)

The thing is that I want the head to actually look at the player. When I run the script, the animation works correctly, but not the Head’s rotation. Does anyone know how to fix this? Here’s a more detailed video:

When creating CFrames, the second parameter is what you want the object to face towards, not the orientation. Try putting the paramater as the player’s head, or humanoid root part.

Should look something like this:

local newPos = CFrame.new(endPosition, playerHead)

-- the parameters here are examples, replace them
1 Like

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