Make a simple model spin like a Minecraft Item

Hello, I’m trying to spin and move my model at the same time. I’ve tried spinning it around, it works, and so does moving it. But the problem is, I can’t get it to work at the same time (moving and spinning both happening at once).

Model: (Has a PrimaryPart set, both handles are welded to the invisible ‘‘part’’)
image

Current Script inside of the PrimaryPart (part):

local tweenService: TweenService = game:GetService("TweenService")

local part: Part = script.Parent

local tweenInfo0: TweenInfo = TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)

local tweenInfo1: TweenInfo = TweenInfo.new(
	5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)

tweenService:Create(part, tweenInfo0, {CFrame = part.CFrame + Vector3.new(0, 1, 0)}):Play()
tweenService:Create(part, tweenInfo1, {Orientation = Vector3.new(0, 360, 0)}):Play()

Result:

How’d I go about fixing this absolute spinning madness?

3 Likes

make them tweens variable so the other tween plays after the other one is finished
example:

local tween1 = tweenService:Create(part, tweenInfo0, {CFrame = part.CFrame + Vector3.new(0, 1, 0)})
tween1:Play()
tween1.Completed:Wait()
local tween2 = tweenService:Create(part, tweenInfo1, {Orientation = Vector3.new(0, 360, 0)})
tween2:Play()
tween2.Completed:Wait()

2 Likes

i just read it wrong whoops after screwing a little just 1 second i kinda fixed it

local tween1 = tweenService:Create(part, tweenInfo0, {CFrame = part.CFrame + Vector3.new(0, 1, 0)})
tween1:Play()

local tween2 = tweenService:Create(part, tweenInfo1, {Orientation = Vector3.new(0, 360, 0)})
tween2:Play()

2 Likes

i dont think you made any errors cause the actual primary part looks fine ingame but anything welded to it looks so spinny
dont take my word for it tho i might be wrong

This won’t change anything, as it does the same thing?

1 Like

yeah it didnt change anything also btw the actual part is working fine and i think its the welds cause when i weld stuff to it they go crazy
i have no idea to fix this

I just tried to use normal welds, the result is still the same.

Could someone help me, it’s still not fixed…

Cant u just use :PivotTo() instead? like in a loop

while true do
  task.wait()
  local part  = script.Parent
  part:PivotTo(part.CFrame * CFrame.Angles(0, math.rad(1) ,0)
  --if u need to pivot a model then use this
  --part:PivotTo(part:GetPivot() * CFrame.Angles(0, math.rad(1) ,0)
end
1 Like

CFrame is both orientation and position which overwrites the Orientation tween. Change CFrame to Position and it should work!

1 Like

Send me the current script. It might have been a typo.

1 Like
local tweenService: TweenService = game:GetService("TweenService")

local part: Part = script.Parent

local tweenInfo0: TweenInfo = TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)

local tweenInfo1: TweenInfo = TweenInfo.new(
	5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)

tweenService:Create(part, tweenInfo0, {CFrame = part.Position + Vector3.new(0, 1, 0)}):Play()
tweenService:Create(part, tweenInfo1, {Orientation = Vector3.new(0, 360, 0)}):Play()

Change this line to:

tweenService:Create(part, tweenInfo0, {Position = part.Position + Vector3.new(0, 1, 0)}):Play()
1 Like

I’ve tried this, it works, the part moves, although position does not affect WeldConstraints.

I would suggest using Welds instead of WeldConstraints since WeldConstraints aren’t as secure as Welds.

1 Like

It doesn’t work on normal Welds either, and I prefer WeldConstraint because of the hacky Weld CFrames.

Try moving the rest of the parts and not just the main part.

1 Like

neviquatro’s Solution seemed to work, I’m just messing around with PivotTo() right now.

1 Like

I would just Recommend you use RunService.RenderStepped for this occasion rather than just using TweenService as an answer to all your problems.

Because this isnt a detail that should be prioritized by the game, it should just taken care of by the Client as an Animation of sorts. What RenderStepped will do here is fire everytime in every frame, prior to physics and I believe prior to Rendering as well, but using this can make the object smoothly rotate along an axis, I would also recommend you utilize CollectionService for this as well, as it will make it easier to control what will be aninated, and what will not.

Tweens will fire constantly, which is why you will see a smooth transition along its path, but because of that, they send a lot of data, one single Tween will not affect your game, but hundreds will slow it down because of the data its sending.

1 Like