Tween Part with CFrame not working

When i tweening part with this script its not moving:

function module.infectPartDownUp(part,color)
	local infectPart = Instance.new("Part",part)
	infectPart.Name = "InfectedPart"
	infectPart.BrickColor = color
	infectPart.Material = Enum.Material.Plastic
	infectPart.CanCollide = false
	local weld = Instance.new("WeldConstraint",infectPart)
	local ySize = part.Size.Y
	infectPart.Size = Vector3.new(part.Size.X,0,part.Size.Z)
	infectPart.CFrame = part.CFrame-(part.CFrame.UpVector*part.Size.Y/2)
	weld.Part0 = infectPart
	weld.Part1 = part
	TweenService:Create(infectPart,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),
		{CFrame = part.CFrame+(part.CFrame.UpVector*part.Size.Y/2),Size = part.Size}):Play()
end

part script:

local db = false
local module = require(game.ServerScriptService.InfectingModuleScript)
script.Parent.ClickDetector.MouseClick:Connect(function()
	if db == false then
		db = true
		module.infectPartDownUp(script.Parent,BrickColor.White())
	end
end)


Whats wrong with my code?

Explain what the problem is as I do not see any problem.

Its should move to center of part

{CFrame = part.CFrame+(part.CFrame.UpVector*part.Size.Y/2)  <--

If you want to move it to the center of the part then just use

{CFrame = part.CFrame} 

Nothing happends, its still on same position

I found that its for some reason dont work with nonanchored parts

Found solution, just use “Weld” with C0 and C1 instead “WeldConstraint”

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.