Please help me with cframes before i loose my mind

I don’t usually run to the devforum but I’ll keep it quick.
I am not a wizard at CFrames, never have been.

I want my NPC / Part if you want to think about it as a part go ahead, no difference.
To spin on its local y axis and local x axis
I have my numbers and etc.

--// this is outside
local defCF = part.CFrame --// before the loop

--// this is in a runservice loop btw
local startCF = CFrame.new(part.Position)
local lookAtCF = defCF.Rotation
	
part.CFrame = startCF 
	* lookAtCF
	* CFrame.Angles(math.rad(sineX), math.rad(sineY), 0)

However, what happens is the sineX suddenly behaves like its moving him on his local Z and forward and back? I’ve got no idea what is going on so I urge you any CFrame wizards out there please do help.

He shouldn’t be facing towards global north, he should just be facing the direction stored in DEFCF and rotating with the numbers with that dir in mind

Just to add on he should remain in his CURRENT position, only his angles should change.

I did a quick search and found this:

Not sure if it’ll help with your rotation, but it’s worth a try.

Unfortunately not, but thanks for your help.

I searched “rotate npc to face a direction” and found a few other posts as well.

local startCF = CFrame.new(part.Position)
local lookAtCF = defCF.Rotation

-- Apply rotations around local Y and X axes
part.CFrame = startCF 
    * lookAtCF
    * CFrame.Angles(math.rad(sineX), 0, 0) -- X axis
    * CFrame.Angles(0, math.rad(sineY), 0) -- Y axis

I have tried separating the rotations into two CFrame.Angles, can you try the script?

Unfortunately I tried this already and yet same result, although cheers for your time and response.

1 Like

Can you send me a footage or video of the issue, so I know where to look at?

wow i have to yap to avoid a limit i imagine for spam?
Anyway please don’t judge me although I don’t expect you to.

--// this is outside
local defCF = part.CFrame --// before the loop

--// this is in a runservice loop btw
local startCF = CFrame.new(part.Position)
local lookAtCF = defCF - defCF.Position

part.CFrame = startCF 
    * lookAtCF
    * CFrame.Angles(math.rad(sineX), 0, 0) -- X axis
    * CFrame.Angles(0, math.rad(sineY), 0) -- Y axis

Try this

Unfortunately not, still same behaviour, thankyou for ur help so far :smiley:

1 Like

Anybody else got any ideas? I’ve been stuck on this for nearly two hours and I wan to go to bed and forget about this.

ok so my own code is affecting itself, its updating its position for no reason.
apparantley its moving itself for some weirdddd reason after its applied each frame

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