Problem with CFrame / Model:PivotTo()

Hello developers, i got a problem making an anime attack… The problem is this

The orientation of the model isn’t right

And this is the code:

-- // Variables \\ --

local RemoteEvent = script.Parent

local TweenService = game:GetService("TweenService")

local Debris = game:GetService("Debris")

local Debounce = false

RemoteEvent.OnServerEvent:Connect(function(player, AbilityModule)
	
	-- // More variables...
	
	local Character = player.Character
	
	local Humanoid = Character:FindFirstChild("Humanoid")
	
	local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
	
	---------------------------------------------
	
	-- // Functionality \\ --
	
	if Debounce == false then
		
		local MagmaModel = script.Parent.VFX.FistVFX:Clone()
		MagmaModel.Parent = HumanoidRootPart
		MagmaModel:PivotTo(HumanoidRootPart.CFrame * CFrame.new(0,3,-10))
		
		local MagmaModelChildrens = MagmaModel:GetChildren()
		
		local TweenInfo = TweenInfo.new(
			0.5,
			Enum.EasingStyle.Quad,
			Enum.EasingDirection.InOut,
			-1,
			true,
			0
		)
		
		for i,v in pairs(MagmaModelChildrens) do
			local Goal = {
				Size = v.Size + Vector3.new(0.5,0.5,0.5)
			}

			local TweenSizeAnimation = TweenService:Create(v,TweenInfo,Goal):Play()
		end
	end
end)

This is the explorer:
image

As you can see, the FistVFX is the magma model.
it contains meshes.

(Btw i started coding this a moment ago)

You can give me ideas on what i can do or if there is a solution.

Thank you!

You should read more about Cframes. When you are setting the CFrame position, mutliply by CFrame.Angles() to get a different rotation.

In your case you need to multiply,

MagmaModel:PivotTo(HumanoidRootPart.CFrame * CFrame.new(0,3,-10) * CFrame.Angles(0,math.rad(-180),0))

Math.rad converts the orientation to something the cframe understands better.

3 Likes