TweenService with primary part

I am VERY new to scripting and I am curious if there is a way to use TweenService With a primary part on a model that has no welds. I tried using quenty’s QPerfectionweld script but that did not work for me because some of the parts in the model do not get tweened.

local player = game.Players.LocalPlayer
local character=player.Character 
local doors = {}
local debounce = {}
local tweenservice=game:GetService("TweenService")

character.HumanoidRootPart.Touched:connect(function(hit)
	if hit.Parent.Name=="Door" then
		local door = hit.Parent
		if not debounce[door] then
			debounce[door]=true
			if doors[door] then
				local goal={CFrame=door:GetPrimaryPartCFrame()*CFrame.Angles(math.rad(-90),0,0)}
				local tween = tweenservice:Create(door.PrimaryPart,TweenInfo.new(2,Enum.EasingStyle.Bounce),goal)
				tween:Play()
				doors[door]=nil
			else
				local goal={CFrame=door:GetPrimaryPartCFrame()*CFrame.Angles(math.rad(90),0,0)}
				local tween = tweenservice:Create(door.PrimaryPart,TweenInfo.new(2,Enum.EasingStyle.Bounce),goal)
				tween:Play()
				doors[door]=true
			end
			delay(5,function()
				debounce[door]=nil
			end)
		end
	end
end)

Please search for related topics first next time. You might find your answer here:

1 Like

a basic user can’t access that topic so this topic can stay

The simplest way to solve this (like stated in the thread buildthomas posted), is to use a CFrameValue. You will tween the Value property of it and then listen to changes on the CFrameValue and set the primary part CFrame to what the value is.

1 Like

When tweening the PrimaryPart (not using :SetPrimaryPartCFrame()) only the connected parts unanchored and connected with constraints or Motor6D will get tweened with it.

He stated that the model was already welded together. The parts that didn’t move had welds in them that were attached to the main part.

And I stated that if he did not use constraint or a Motor6D, he would have the issue. That means if the script he used to weld it used regular Welds (the object), they wouldn’t move when he tries to CFrame the PrimaryPart. He needs Motor6D for that behavior, or possibly one of the newer constraint types.

I also threw in the thing about anchor-state just in case.

1 Like