Weld tweening not working as intended

Hey! I’m trying to tween a SnowPlow that is welded to a vehicle. The “SnowDown” tween works perfectly, however, the “SnowUp” doesn’t tween at all (other parts like the hydraulicsSound work).

I’ve tried numerous ideas, but I wasn’t able to fix this issue. Any idea?

ServerScript

	local plowUpPart = car:WaitForChild("Body").SnowPlow.UP
	local plowDownPart = car:WaitForChild("Body").SnowPlow.Down

	local upWeld, downWeld, C1upWeld
	for _, weld in pairs(car:WaitForChild("DriveSeat"):GetChildren()) do
		if weld.Name == "UP" and weld.Active then
			upWeld = weld
			C1upWeld = upWeld
		elseif weld.Name == "Down" and weld.Active then
			downWeld = weld
		end
	end

	if not upWeld or not downWeld then
		return
	end

	local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	if argument == "SnowDown" then
		local goal = {C1 = downWeld.C1}
		local tween = TweenService:Create(upWeld, tweenInfo, goal)
		tween:Play()

		plowUpPart:SetAttribute("plowPosition", "Down")
		
		playHydraulicsSound()
	elseif argument == "SnowUp" then
		local goal = {C1 = C1upWeld.C1}
		local tween = TweenService:Create(upWeld, tweenInfo, goal)
		tween:Play()

		plowUpPart:SetAttribute("plowPosition", "Up")

		playHydraulicsSound()
	end

Can you show us a video of it? So we better understand the issue?

1 Like

Here, try this.

local plowUpPart = car:WaitForChild("Body").SnowPlow.UP
local plowDownPart = car:WaitForChild("Body").SnowPlow.Down

local upWeld, downWeld, C1upWeld
local upWeldC1,downWeldC1
for _, weld in pairs(car:WaitForChild("DriveSeat"):GetChildren()) do
	if weld.Name == "UP" and weld.Active then
		upWeld = weld
		C1upWeld = upWeld
	elseif weld.Name == "Down" and weld.Active then
		downWeld = weld
	end
end

upWeldC1 = upWeld.C1
downWeldC1 = downWeld.C1

if not upWeld or not downWeld then
	return
end

local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
if argument == "SnowDown" then
	local goal = {C1 = downWeldC1}
	local tween = TweenService:Create(upWeld, tweenInfo, goal)
	tween:Play()

	plowUpPart:SetAttribute("plowPosition", "Down")

	playHydraulicsSound()
elseif argument == "SnowUp" then
	local goal = {C1 = upWeldC1}
	local tween = TweenService:Create(upWeld, tweenInfo, goal)
	tween:Play()

	plowUpPart:SetAttribute("plowPosition", "Up")

	playHydraulicsSound()
end

If it works, I’ll explain what the issue was.

2 Likes

Thanks for the reply! However, unfortunately, it still doesn’t work.

Interesting. I think I know the issue a bit but it’s because C1upWeld just happens to be your weld. You need to save the weld values prior to tweening the weld.

2 Likes

Also why not use the Attribute of the plowPosition Up or Down to select which way the input changes the plow direction. It saves you setting up another variable that you’re duplicating.

if plowUpPart.Attribute = "Up" then 
    -- code to move plow down
else 
    -- code to move plow up
end

Where are you setting the variable argument for the if check?

If my suggestions do not work try printing your upWeld.C1 and downWeld.C1 variable values in their respective sections of the code to see if they are both equal to the same value.

Weird, new computer and it's giving me strange text with the use of single quote marks and backticks...
2 Likes

No, that’s not the issue, or at least shouldn’t be. The function checks for welds that are named “UP” (or “Down” in the other case) and that are Active. Then it sets that weld it finds to the variable.

Also I’m getting the argument from an event, the script that I provided is not full. However, you’re right that I can just use the attribute.

1 Like

So did you try saving the values before manipulating everything?

Because I think the issue works like this:

	local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	if argument == "SnowDown" then
		local goal = {C1 = downWeld.C1} -- snow plow goes down, pretty nice!
		local tween = TweenService:Create(upWeld, tweenInfo, goal)
		tween:Play()

		plowUpPart:SetAttribute("plowPosition", "Down")
		
		playHydraulicsSound()
	elseif argument == "SnowUp" then
		local goal = {C1 = C1upWeld.C1} -- do remember, we set C1upWeld to our "upWeld"
		local tween = TweenService:Create(upWeld, tweenInfo, goal) -- oh no, doesn't work!! Why? because the goal is set to our current upWeld's C1. It needs to be the old one.
		tween:Play()

		plowUpPart:SetAttribute("plowPosition", "Up")

		playHydraulicsSound()
	end
2 Likes

Well I did try doing that with the C1upWeld. I set it at the beginning to the original upWeld value. Or at least tried to do that.

1 Like

So what happens when you print upWeld.C1 and downWeld.C1?

1 Like

Hmm, can’t you just record the values of everything? And set them using CFrames?

2 Likes

That’s the issue, I can’t tween the CFrame. Wanted to do it, but it can only tween if the part is anchored. However, as it’s a vehicle, it obviously cannot be anchored and needs to be welded to the car. Welds then don’t have a CFrame property, so that’s why I need to do this.

1 Like

Last time I checked they were just (obviously) the same, or very similar values, not sure about now, I changed parts of the code quite a lot beforehand.

1 Like

I see…

You’re using welds to only rotate the plow right? Not move it or anything correct?
If so, then you can use HingeConstraints with their AcutatorType set to Servo.
This way, you can easily manipulate the angles without having to use welds.

2 Likes

I’ve used welds this way and it’s really effective for moving vehicle Parts and saves you using yet another Constraint.

2 Likes

I’m just doing these two movements - up and down. It then stays still.

And not really sure, hinges sound kinda harder for me to do. I’d rather get this fixed somehow, but idrk.

1 Like

You’re not wrong here. I wanted to suggest an alternative because the issue is a bit weird? Like I suspect it to be fixed by properly assigning upWeld and such, yet it doesn’t work.

Alright, apologies.

1 Like

A bit similar to my previous reply but try this:

local plowUpPart = car:WaitForChild("Body").SnowPlow.UP
local plowDownPart = car:WaitForChild("Body").SnowPlow.Down

local upWeld
local upWeldC1,downWeldC1
for _, weld in pairs(car:WaitForChild("DriveSeat"):GetChildren()) do
	if weld.Name == "UP" and weld.Active then
		upWeld = weld
		upWeldC1 = weld.C1
	elseif weld.Name == "Down" and weld.Active then
		downWeldC1 = weld.C1
	end
end

if not upWeld or not downWeldC1 then
	return
end

local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local goal
if argument == "SnowDown" then
	goal = {C1 = downWeldC1}
	plowUpPart:SetAttribute("plowPosition", "Down")
elseif argument == "SnowUp" then
	goal = {C1 = upWeldC1}
	plowUpPart:SetAttribute("plowPosition", "Up")
end
local tween = TweenService:Create(upWeld, tweenInfo, goal)
tween:Play()
playHydraulicsSound()
2 Likes

Unfortunately, that didn’t help either :sweat_smile:

1 Like