Hello devs!
I’m trying to make a simple pipe wire puzzle that connect with earch other.
The problem is somehow, I keep getting this:

How it’s supposted to looks like.

How it looks like.
The pipes don’t care if the wire breakup, they just care up on having a powered wire connected.
Here’s my code:
local tween = game:GetService("TweenService")
local info = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
local possibleRotations = {
90,
180,
}
local debounce = false
local number = math.random(1,2)
script.Parent.MouseClick:Connect(function()
if debounce == false then
debounce = true
local tween1 = tween:Create(script.Parent.Parent, info, {CFrame = script.Parent.Parent.CFrame * CFrame.Angles(0, 0, math.rad(90))})
tween:Create(script.Parent.Parent.HitBox, info, {CFrame = script.Parent.Parent.CFrame * CFrame.Angles(0, 0, math.rad(90))}):Play()
tween:Create(script.Parent.Parent.ColorTube, info, {CFrame = script.Parent.Parent.CFrame * CFrame.Angles(0, 0, math.rad(90))}):Play()
script.Parent.Parent.Powered.Value = false
script.Parent.Parent.ColorTube.Color = Color3.new(0,0,0)
tween1:Play()
tween1.Completed:Connect(function()
debounce = false
end)
end
end)
while true do
task.wait(.1)
local amount = 0
if #script.Parent.Parent.HitBox:GetTouchingParts() > 0 then
for i, v in pairs(script.Parent.Parent.HitBox:GetTouchingParts()) do
if v.Name == "HitBox" and v.Parent.Powered.Value == true then
if script.Parent.Parent.Powered then
script.Parent.Parent.Powered.Value = true
tween:Create(script.Parent.Parent.ColorTube, info, {Color = Color3.new(0, 0.333333, 0)}):Play()
else
script.Parent.Parent.Powered.Value = false
tween:Create(script.Parent.Parent.ColorTube, info, {Color = Color3.new(0, 0, 0)}):Play()
end
end
end
else
script.Parent.Parent.Powered.Value = false
tween:Create(script.Parent.Parent.ColorTube, info, {Color = Color3.new(0, 0, 0)}):Play()
end
end
Here the pipe folder:
