How do you animate doors of a car that is welded?

im trying to animate my car doors, i want them to open up like the car on the left. im intending to script the car so i need it to be unanchored.

i tried something based on this solution in another post but no luck.

tween the welds c0/c1 for the doors

2 Likes

For the latch have it welded to the door at the point you want it to slide at.
As @PreciseGaps said, tween the WeldC0 or the WeldC1 property.

Here’s the code I wrote for some observatory doors in rotating dome. It’s not the same thing, but it shows how to make the tween affect the weldC0.

tweenService = game:GetService("TweenService")
prompt = script.Parent.Main.ProximityPrompt

door1 = script.Parent.Door1.Door1.Weld
door2 = script.Parent.Door2.Door2.Weld

tweenInfo = TweenInfo.new(
		6,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut			
		)

tweenOpen1 = tweenService:Create(door1, tweenInfo, {C0 = CFrame.new(0,0,0)})
tweenOpen2 = tweenService:Create(door2, tweenInfo, {C0 = CFrame.new(0,0,0)})

tweenClose1 = tweenService:Create(door1, tweenInfo, {C0 = CFrame.new(1.39,0,0)})
tweenClose2 = tweenService:Create(door2, tweenInfo, {C0 = CFrame.new(-1.39,0,0)})

prompt.Triggered:Connect(function()

	if prompt.ActionText == "Close" then
		prompt.Enabled = false
		tweenClose1:Play()
		tweenClose2:Play()
		task.wait(6)
		prompt.ActionText = "Open"
		prompt.Enabled = true
	else
		prompt.Enabled = false
		tweenOpen1:Play()
		tweenOpen2:Play()
		task.wait(6)
		prompt.ActionText = "Close"
		prompt.Enabled = true
	end
	
end)
1 Like

thanks very much for your help bro. i got it eventually. u legend!!

1 Like

thank u so much for ur help Scott,
i finally got it to work after hours of reading up about how to do this; your sample code was very helpful mate. thank u so much!!

for anyone tryna do this as well i made the model free on the creator store

I probably had the same issue with trying to find out how to exactly change the C0 value. A lot of the Roblox documentation is kind of vague about this.
I finally used the Studio Assistant and got it to write some sample code of how to tween a weld’s C0 property and that helped me add those lines into my script.

1 Like

sample code goes a hell of a long way 100%. i just didnt think like you needed to tween the weld or whatever but u do. and as u said the documentation is very vague on this sort of thing.

apologies for bothering you again but i just have a question about getting the C0 positions of the car doors right. i get the position of the C0 in the weld with 2 models. i copy the position of the C0 from the closed doors model and copy the opened doors position from the C0 in the other car model. is this the most efficient way to go about this or is there any more intuitive way to do it?
cheers mate

For the rotation of the doors? I’d just have the weld C1 Position at the hinge location and change the orientation of the C0 from 0 to 45° (or whatever you are using.
For the latch you can weld it to the door at it’s location using the C1 and then just change the C0 for the tween.
It’s a bit easier when you are only dealing with only one of them. That way if you want to move the latch you can just change 1 of the values, or if you want to change how much it slides change the other ones for the script.

1 Like

perfect Scott,
thanks a million for your help. i’ll make sure to try that next time. im trying to be as efficient as possible. :slight_smile:

1 Like

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