Hello there users of devforum. I have created this script where an enemy team will go through a metal detector and it’ll make an alarm. So far, everythings been done. But i am adding a feature of a way of hacking it and it’s not working correctly. No matter what if its hacked it’ll keep on alarming.
As shown in this video. When its at its normal color it means not hacked but when its red it means hacked… I used print and other debugs and it seems to work so I don’t understand whats happening…
TouchPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~= nil and not debounce and ishacked == false then
debounce = true
if player.TeamColor == BrickColor.new("Lily white") or player.TeamColor == BrickColor.new("Deep orange") then
Alarm.BrickColor = BrickColor.new("Really red")
script.Parent.DetectedNonAllie:Play()
script.Parent.DetectedNonAllie.Looped = false
task.wait(5)
Alarm.BrickColor = BrickColor.new("Neon orange")
elseif player.TeamColor ~= BrickColor.new("Lily white") or player.TeamColor == BrickColor.new("Deep orange") then
Alarm.BrickColor = BrickColor.new("Lime green")
script.Parent.DetectedAllie:Play()
script.Parent.DetectedAllie.Looped = false
task.wait(5)
Alarm.BrickColor = BrickColor.new("Neon orange")
importantbrick:GetPropertyChangedSignal("BrickColor"):Connect(function()
if ishacked == false then
ishacked = true
TouchPart.Touched:Connect(function()
if player.TeamColor == BrickColor.new("Lily white") then
Alarm.BrickColor = BrickColor.new("Lime green")
script.Parent.DetectedAllie:Play()
script.Parent.DetectedAllie.Looped = false
task.wait(5)
Alarm.BrickColor = BrickColor.new("Neon orange")
end
end)
end
end)
end
wait(1)
debounce = false
end
end)