hi, so basically I have this little control room alarm script right, and
On Code 1
we can see it using Directory.WhiteTrigger.KeyCardReader1.KeyCardReader:FindFirstChild(“Light”).Color that works perfectly just fine in this part of code, however SOMEHOW in the function which is called out in this script Code2
“Initiate Cooldown” it dropps me an error Workspace._TRIGGERS.ControlRoom.Handler:36: attempt to index nil with 'Color'
Can someone tell me how is that possible? First it works in Code 1
and after that in the same script it refuses to work with the same parts it? I don’t get it
Code 1
function TriggerWhite(player)
KeycardAccess = Directory.WhiteTrigger.KeycardAccess
local KeycardRank = CheckKeycard(player)
if KeycardRank ~= nil and KeycardAccess:FindFirstChild(KeycardRank).Value then
DisableCodes()
Directory.WhiteTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Success
warn("//CR: PROTOCOL ACTIVATED - CODE WHITE")
NotifyEvent:FireAllClients( 1,"SITE STATUS UPDATED", "CURRENT SECURITY PROTOCOL \n \n CODE WHITE")
SecurityCode.Value = "CODE WHITE"
Directory.WhiteTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Success
for _, model in pairs(Spakers:GetChildren()) do
for _, part in pairs(model:GetChildren()) do
for _, sound in pairs(part:GetChildren()) do
if sound:IsA("Sound") and sound.Name == "AnnounceSound" then
sound.SoundId = WHITE_SFX_V
sound:Play()
elseif sound:IsA("Sound") and sound.Name == "AlarmSound" then
sound:Stop()
end
end
end
end
InitiateCooldown()
EnableCodes()
else
-- Keycard access denied
print("Access denied. Insufficient keycard level.")
Directory.WhiteTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Failed
wait(5)
Directory.WhiteTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Default
end
end
Code2
function InitiateCooldown()
print("Site Protocol Cooldown started")
for CooldoolDown = 30, 0, -1 do
print("SSC:\\ "..CooldoolDown)
Directory.WhiteTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Reboot
Directory.YellowTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Reboot
Directory.RedTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Reboot
Directory.BlackTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Reboot
Directory.OrangeTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Reboot
Directory.PurpleTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Reboot
wait(1)
Directory.WhiteTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Default
Directory.YellowTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Default
Directory.RedTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Default
Directory.BlackTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Default
Directory.OrangeTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Default
Directory.PurpleTrigger.KeyCardReader1.KeyCardReader:FindFirstChild("Light").Color = COLOR_SCHEME.Default
wait(1)
end
wait(1)
return
end```