So basically I’m making a system that detects the player’s team and if they have a certain tool in their backpack. And if they do, the alarm will go off until that player is killed. The problem is I’m not sure why it isn’t working, and there are no errors, and I’m not sure how to add the system that detects if the player is killed.
Here’s the script:
local alarmsound = script.Parent.Parent.AlarmSound
local part = script.Parent
local weppons = {
["[SCP] Card-Omni"] = true,
["Gun1"] = true,
["Gun2"] = true,
["Gun3"] = true,
["Gun4"] = false
}
function triggerAlarm()
alarmsound:Play()
end
local function onPartTouched(hit)
local IsInBackpack = false
for index, v in pairs(weppons) do
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player.Backpack:FindFirstChild(index) then
if player.Team.Name == "Class-D" then
IsInBackpack = true
end
end
end
if IsInBackpack then
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Really red")
script.Parent.Parent.Light2.brickColor = BrickColor.new("Really red")
triggerAlarm()
else
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Lime green")
script.Parent.Parent.Light2.brickColor = BrickColor.new("Lime green")
wait(1)
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Lily white")
script.Parent.Parent.Light2.brickColor = BrickColor.new("Lily white")
end
end