Cframe angles not working in functions?

For some reason, whenever I put this line of code on a serverscript inside a function:

Helicopter:SetPrimaryPartCFrame(Helicopter.HeliBody.CFrame * CFrame.Angles(0,0,math.rad(2)))

It does not work, if i put it out of the function in a serverscript, then it works. If i put it in a localscript function, it works.

game.ReplicatedStorage.ChangeD.OnServerEvent:Connect(function(player)
	local Helicopter = game.Workspace.Helicopter
	Helicopter:SetPrimaryPartCFrame(Helicopter.HeliBody.CFrame * CFrame.Angles(0,0,math.rad(2)))
end)

Serverscript ^

Why wont it work while its in a function? (When i do setprimarypart vector3.new() in a function, it works. Its just cframe. angles

any help?

by function do you mean server event specifically, or just any function? also SetPrimaryPartCFrame(Vector3.new()) shouldn’t work because you are setting a CFrame, if you wanted just a vector you would do CFrame.new(Vector3.new())

any function, and for the setprimarypartcframe thing i was just saying that i did vector3.new to move it up an down - that wasnt the actual thing i used, i used Helicopter:SetPrimaryPartCFrame(Helicopter.HeliBody.CFrame + Vector3.new(0,-.5,0))

if i put the angles code outside of the onserverevent function, boom it works- or any function for that matter

Are you sure it’s even noticable? math.rad() converts radians to degrees, and so instead of using 2 radians, it’s only changing 2 degrees

Yes, I tried 45 too and it didnt work.

also i did prints so i know its getting to the line

the helicopter definitely has a primary part right?, also I take it there’s no errors

Yeah cause it works for every other time, like if i put it outside the function it works, and if i try to move it up with the vector3.new() it works, soo yes

and yeah, no errors

when you move it outside of the function, add a print, if it doesn’t print then something is yielding

add a print where? inside the onserverevent function?

where you moved it when you said you moved it outside of the function

I just moved it into a empty place in the script

also if i take the angle code out of the onserverevent function and just a print inside it, it prints it

by empty place do you mean there’s nothing before it? because it’s what’s before it is what counts, because I’m pretty sure functions like that run on a different thread, so I’m asking if there’s a likely chance its yielding, still print anyway outside of the function just to see if it does at all

empty place like, after all the onserverevent functions to change the positions of the helicopter, after that i put it, and i put a print and it works. Its just when i put it inside the function