Rotating and Moving a Model at the same time

Hello, I am trying to rotate and move a model at the same time, but it only moves it.
Here is my script:

local RunService = game:GetService("RunService")

while true do
	
	for i = 1, 100 do
		RunService.Heartbeat:Wait()
		script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.PrimaryPart.Position + Vector3.new(0,.5, 0)) * CFrame.Angles(0, math.rad(1), 0))
	end
	for i = 1, 100 do
		RunService.Heartbeat:Wait()
		script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.PrimaryPart.Position - Vector3.new(0,.5, 0)) * CFrame.Angles(0, math.rad(1), 0))
	end
end

Thanks :smiley:

2 Likes

It looks like you are trying to make the pickup able item effect.

The issue here is that the previous CFrame is not taken accounted for and is being set a static CFrame.angles value. Another issue is using set primary part CFrame which I discourage as it can get buggy overtime for this scenario see within engine bugs

Here is my take using sin to do the task:

This doesn’t really work since Cframe isn’t a property of the model. Should I add setPrimaryPartCFrame?

Well here is what you can do if you still want to use set primary part CFrame.

Set it equal to

Model.PrimaryPart.CFrame*CFrame.new(0,0.5,0)*CFrame.Angles(0,math.rad(1),0)

To take into account the previous parts rotation and position.

2 Likes

Thanks, it works, however, when the player jumps on to it, it starts vibrating, how could I fix that?

Try out the methods posted here:

I will try them out, but what could be the cause of this vibration?

sorry you have a answer for problem ?