Stick two parts together

Oh yes sure. Here it is:

local ClosedC0 = CFrame.new(4.29153442e-06, 3.81469727e-06, 1.9499979, 1, 0, 0, 0, 1, 0, 0, 0, 1)
local OpenC0 = CFrame.new(4.29153442e-06, -0.846243143, 3.2851181, 1, 0, 0, 0, 0.579398692, -0.815044284, 0, 0.815044284, 0.579398692)
local stove = script.Parent:WaitForChild("Stove")
local buttons = stove:WaitForChild("Buttons")
local Elements = stove:WaitForChild("HeatingElements")
local lid = script.Parent.Oven.Body.Lid

for _, v in pairs(buttons:GetChildren()) do
	if v.Name == "Button1" then
		local CD = v.Click
		local Box = v.Box
		CD.MouseHoverEnter:Connect(function()
			Box.Visible = true
		end)
		CD.MouseHoverLeave:Connect(function()
			Box.Visible = false
		end)
		CD.MouseClick:Connect(function()
			if Elements.E1.State.Value == false then
				Elements.E1.State.Value = true
				Elements.E1.Material = Enum.Material.Neon
				Elements.E1.BrickColor = BrickColor.new("Really red")
			elseif Elements.E1.State.Value == true then
				Elements.E1.State.Value = false
				Elements.E1.Material = Enum.Material.Metal
				Elements.E1.BrickColor = BrickColor.new("Smoky grey")
			end
		end)
	elseif v.Name == "Button2" then
		local CD2 = v.Click
		local Box2 = v.Box
		CD2.MouseHoverEnter:Connect(function()
			Box2.Visible = true
		end)
		CD2.MouseHoverLeave:Connect(function()
			Box2.Visible = false
		end)
		CD2.MouseClick:Connect(function()
			if Elements.E2.State.Value == false then
				Elements.E2.State.Value = true
				Elements.E2.Material = Enum.Material.Neon
				Elements.E2.BrickColor = BrickColor.new("Really red")
			elseif Elements.E2.State.Value == true then
				Elements.E2.State.Value = false
				Elements.E2.Material = Enum.Material.Metal
				Elements.E2.BrickColor = BrickColor.new("Smoky grey")
			end
		end)
	elseif v.Name == "Button3" then
		local CD3 = v.Click
		local Box3 = v.Box
		CD3.MouseHoverEnter:Connect(function()
			Box3.Visible = true
		end)
		CD3.MouseHoverLeave:Connect(function()
			Box3.Visible = false
		end)
		CD3.MouseClick:Connect(function()
			if Elements.E3.State.Value == false then
				Elements.E3.State.Value = true
				Elements.E3.Material = Enum.Material.Neon
				Elements.E3.BrickColor = BrickColor.new("Really red")
			elseif Elements.E3.State.Value == true then
				Elements.E3.State.Value = false
				Elements.E3.Material = Enum.Material.Metal
				Elements.E3.BrickColor = BrickColor.new("Smoky grey")
			end
		end)
	elseif v.Name == "Button4" then
		local CD4 = v.Click
		local Box4 = v.Box
		CD4.MouseHoverEnter:Connect(function()
			Box4.Visible = true
		end)
		CD4.MouseHoverLeave:Connect(function()
			Box4.Visible = false
		end)
		CD4.MouseClick:Connect(function()
			if Elements.E4.State.Value == false then
				Elements.E4.State.Value = true
				Elements.E4.Material = Enum.Material.Neon
				Elements.E4.BrickColor = BrickColor.new("Really red")
			elseif Elements.E4.State.Value == true then
				Elements.E4.State.Value = false
				Elements.E4.Material = Enum.Material.Metal
				Elements.E4.BrickColor = BrickColor.new("Smoky grey")
			end
		end)
	end
end

local TS = game:GetService("TweenService")

local info = TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0)

local OpenGoal = {
	C0 = OpenC0
}

local CloseGoal = {
	C0 = ClosedC0
}
local open = TS:Create(lid, info, OpenGoal)

local close = TS:Create(lid, info, CloseGoal)

local tweenplaying = false

function handleDoor(state)
	if not tweenplaying and state.Value == "Closed" then
		tweenplaying = true
		open:Play()
		wait(2)
		state.Value = "Open"
		tweenplaying = false
	elseif not tweenplaying and state.Value == "Open" then
		tweenplaying = true
		close:Play()
		wait(2)
		state.Value = "Closed"
		tweenplaying = false
	end
end

lid.Parent.Parent.OvenHandle.Click.MouseHoverEnter:Connect(function()
	lid.Parent.Parent.OvenHandle.Box.Visible = true
end)

lid.Parent.Parent.OvenHandle.Click.MouseHoverLeave:Connect(function()
	lid.Parent.Parent.OvenHandle.Box.Visible = false
end)

lid.Parent.Parent.OvenHandle.Click.MouseClick:Connect(function()
	handleDoor(lid.Parent.Parent.OvenHandle.State)
end)

What I did was join in place the lid and body using a weld plugin in 2 positions, open and closed, and copied the C0 and C1 values of the weld(s) created. Then, I made tables containing the Goal of it smoothly opening and closing. Then when I click the button, it plays the smooth tween, changing the C0 and C1 of the joint and vice versa.

the rest of the code just turns the heating elements on and off.

Hope this helped you learn.

1 Like

May I ask, what is C0 and C1 anyways? Also, could I get a link to the weld plugin you used and one more thing, I wanted to know how you got the actual C0 and C1 values in the first place? Thank you so much!

The plugin I used:
(I had no Idea it was offsale lol) I guess i’m never going to grow my plugin sales if this is the kind of feedback i’m getting
https://www.roblox.com/library/6705791540/WeldEdit
(Click on “Get C0 and C1”), and “Weld” to join in place
What C0 and C1 is:
The offset between the two parts that are inside a weld. It can be rotational too, hence its use in my oven thing.
But remember to keep the weld there in the closed position so it can be rotated properly.

1 Like

Sorry but for one thing, the plugin is offsale. Secondly, the user who made it (your alt I’m presuming from the name of the account) isn’t “verified” and I’m not sure if it’s safe to use especially since it needs script injection. Are there any other weld plugins that you could recommend? Thanks!

Sure! Try using “Moon Animator” Easy Weld. (You can verify the plugin by using InsertService to insert the script, I do it every time before installing a new plugin. Also Moon Animator is a very trusted plugin, and even RFMC [Roblox Film and Media Community] uses it.). But, it doesn’t have a C0+C1 utility, so you must print it manually by doing this:
print(Weld.C0); print(Weld.C1)

1 Like

Thanks a lot! One final question to bother you with :grinning: When do I weld the part? By that I mean, do I put the part in the “final position” and then do the weld? Thank you so much!

Weld 2 times. 1 time in the original position to be welded to (keep that weld), and another in the position of the opened gate (delete that and keep the origin weld to rotate.)

1 Like

Thank you! This really helped!

1 Like

You’re welcome. I’m always happy to help people learn.

Wait a minute…
How did you know it used script injection?
[OHHH I put it in the desc]