Rotating a Model Using Tweenservice

Hello, i am trying to make the vfx to rotate using tweenservices, between the vfx is welded to the player. I have tried many different ways and functions, but nothing working. So my issue is that the part isn’t rotating. I hope that someone can help me to find the solution. I will leave the code and a pircture of how i welded the model down below.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local tweenService = game:GetService("TweenService")
local Replicated = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")

local function PlayTween(object)
	local goal = {}
	goal.CFrame = object.CFrame * CFrame.Angles(math.rad(360),0,0)
	
	local info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,10,true,wait())
	local tween = tweenService:Create(object,info,goal)
	tween:Play()
end

UIS.InputBegan:Connect(function(input, gameprog)
	if gameprog then return end
	if char.Humanoid.Health <= 0 then return end
	
	if input.KeyCode == Enum.KeyCode.R then
		local clone = Replicated:WaitForChild("FX"):Clone()
		clone.PrimaryPart.CFrame = char.PrimaryPart.CFrame
		clone.Parent = char
		
		local weld = Instance.new("Weld", char.PrimaryPart)
		weld.Part0 = char.PrimaryPart
		weld.Part1 = clone.PrimaryPart
		weld.C0 = weld.C0 * CFrame.Angles(math.rad(0),math.rad(0),math.rad(90)) -- To spawn the part on the right side i want
		
		PlayTween(clone.PrimaryPart)
	end
end)
1 Like

Don’t use a weld constraint, use a motor 6d.

Still not rotating, did it work for you? Do i need also to use motor 6d on the weld between the body and the fx.

okey nvm it doesn’t work either

I mean weld it with a motor6d, then tween it’s C0.

I’ve found the best way to tween a Model using TweenService is just to tween the Value property of a CFrameValue, and use the Value as the PrimaryPart’s CFrame.

Here’s an extract from my “DoorAnimation” script, which causes doors to swing open when the player is nearby, to better explain what I mean:

local Doors = BasicState.new(); do
	local TaggedDoors = CollectionService:GetTagged("door")
	
	for _, Door in next, TaggedDoors do
		assert(Door.PrimaryPart, string.format("%s was tagged as a door, but it does not have a PrimaryPart (Hinge)", Door:GetFullName()))
		
		local isLeft = CollectionService:HasTag(Door, "left")
		local CFrameObj = Instance.new("CFrameValue")
		CFrameObj.Value = Door:GetPrimaryPartCFrame()
		
		Vectors[Door] = Door:GetPrimaryPartCFrame().Position
		Doors:RawSet(Door, false)
		
		Tweens[Door] = {
			Active = nil,
			CFrame = CFrameObj,
			Closed = Door:GetPrimaryPartCFrame(),
			Opened = Door:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(Const.OpenAngle * (isLeft and -1 or 1)), 0)
		}
		
		CFrameObj.Changed:Connect(function()
			Door:SetPrimaryPartCFrame(CFrameObj.Value)
		end)
		
		Doors:GetChangedSignal(Door):Connect(function(NewValue)
			if Tweens[Door].Active then
				Tweens[Door].Active:Destroy()
			end
			
			local NewCFrame = NewValue and Tweens[Door].Opened or Tweens[Door].Closed
			
			Tweens[Door].Active = TweenService:Create(
				CFrameObj,
				TweenInfo.new(NewValue and 2 or 1, Enum.EasingStyle[NewValue and "Elastic" or "Quad"]),
				{ Value = NewCFrame }
			)
			
			Tweens[Door].Active:Play()
		end)
	end
end
2 Likes