So this is the Control Panel and the buttons in here are all managed by a script called “Main” in workspace that handles all the control panels and the buttons inside it and they all use a clickdetector.
This was working perfectly fine until one day it suddenly stopped working and you cant click on them anymore even tho it has a ClickDetector inside it.
Little snippet of “Main” Code
print(v:IsA("ClickDetector"))
if v:IsA("ClickDetector") then
v.MouseClick:Connect(function(plr)
print(plr)
end)
if v.Parent.Name == "G" then
local room = v.Parent.Parent.Parent.Parent
local doing = false
v.MouseClick:Connect(function(plr)
if room.Owner.Value == plr or room.Owner.Value == nil then
if doing == false then
doing = true
if room.Robot:FindFirstChildWhichIsA("Model") then
local Robot = room.Robot:FindFirstChildWhichIsA("Model")
local Humanoid = Robot:FindFirstChild("Humanoid")
local Torso = Robot:FindFirstChild("Torso")
if Torso then
local GasPlace = room.Gas
for _, v in pairs (GasPlace:GetDescendants())do
if v.Name == 'Receptor' then
v.Smoke.Enabled = true
end
end
--Humanoid.HealthChanged:Connect(function(health)
-- if health <= 0 then
-- local GasPlace = room.Gas
-- for _, v in pairs (GasPlace:GetDescendants())do
-- if v.Name == 'Receptor' then
-- v.Smoke.Enabled = false
-- end
-- end
-- end
--end)
--local Explosion = Instance.new("Explosion")
--Explosion.Visible = false
--Explosion.BlastRadius = 10
--Explosion.BlastPressure = 0
--Explosion.Position = Torso.Position
--Explosion.Parent = Torso
local random = Random.new()
local Num = random:NextNumber(0.8, 1.2)
local sound = Instance.new("Sound", Torso)
sound.SoundId = "rbxassetid://1388740053"
sound.RollOffMode = Enum.RollOffMode.LinearSquare
sound.RollOffMaxDistance = 75
sound.RollOffMinDistance = 0
sound.PlaybackSpeed = Num
sound.Volume = 5
--sound:Play()
local humList = {}
for i = 1, 100 do
task.wait(2.3)
if Humanoid.Health > 0 then
table.insert(humList, Humanoid)
local op = OverlapParams.new()
op.FilterType = Enum.RaycastFilterType.Include
op.FilterDescendantsInstances = {workspace.IgnoreParts.Characters}
for _,v in pairs(workspace:GetPartBoundsInBox(room.Ground.CFrame, room.Ground.Size)) do
local hum = v.Parent:FindFirstChildOfClass("Humanoid") or v.Parent.Parent:FindFirstChildOfClass("Humanoid")
if hum and hum.Health > 0 and not hum.Parent:FindFirstChild("Hazmat") then
table.insert(humList, hum)
end
end
for _, hum in pairs(humList) do
hum:TakeDamage(2)
local cough
local coughSound = game:GetService("ReplicatedStorage").Miscs.CoughSounds:GetChildren()[math.random(1,3)]
if hum:FindFirstChildOfClass("Animator") then
cough = hum.Animator:LoadAnimation(script.Cough)
else
cough = hum:LoadAnimation(script.Cough)
end
cough:Play()
-- lazy scripting because i’m very busy
--if not Torso:FindFirstChild("Cough Dry 4 (SFX)") then
local found = false
for i, v in pairs(Torso:GetChildren()) do
if string.sub(v.Name, 1, 10) == "Cough Dry " then
found = true
end
end
if not found then
local clone = coughSound:Clone(); clone.Parent = Torso
clone:Play()
end
--end
end
table.clear(humList)
else
doing = false
break
end
end
local Num1 = random:NextNumber(-0.5, 0.5)
local Num2 = random:NextNumber(-0.5, 0.5)
local GasPlace = room.Gas
for _, v in pairs (GasPlace:GetDescendants()) do
if v.Name == 'Receptor' then
v.Smoke.Enabled = false
end
end
--for i, v in pairs(Robot:GetChildren()) do
--if v:IsA("BasePart") then
--local BodyForce = Instance.new("BodyForce")
--local Pos1 = v.Position
--local Pos2 = Explosion.Position - Vector3.new(Num1,0,Num2)
--local Distance = (Pos1 - Pos2)
--local RadiusDistance = math.clamp(20 - Distance.Magnitude,0,20)
--BodyForce.Force = Distance.Unit * (RadiusDistance * math.random(50, 100))
--BodyForce.Parent = v
--print(BodyForce.Force)
--game.Debris:AddItem(BodyForce,0.1)
--end
--end
end
end
--[[
if room.Robot:FindFirstChildWhichIsA("Model") then
local Robot = room.Robot:FindFirstChildWhichIsA("Model")
local Torso = Robot:FindFirstChild("Torso")
if Torso and Torso:FindFirstChild("Neck") then
Torso.Neck:Destroy()
end
end
room.Gasy.Value = true
room.Ground.Gas.Playing = true
v.Parent.Sound:Play()
local gas = room.Ground.Killgas.gas:Clone()
gas.Parent = room.Robot:FindFirstChildOfClass("Model")
gas.Disabled = false
for i,v in pairs(room.Gas:GetChildren()) do
if v:IsA("Part") and v.Name == "Receptor" then
v.Smoke.Enabled = true
end
end
wait(10)
for i,v in pairs(room.Gas:GetChildren()) do
if v:IsA("Part") and v.Name == "Receptor" then
v.Smoke.Enabled = false
end
end
room.Ground.Gas.Playing = false
]]--
wait(2)
doing = false
--room.Gasy.Value = false
end
end
end)```