Object value seems to be changing to nil
local cond = false
print(inventory.Equipped.Value)
if inventory.Equipped.Value then
print(inventory.Equipped.Value:GetAttribute("Weapon"))
end
if inventory.Equipped.Value and inventory.Equipped.Value:GetAttribute("Weapon") then
cond = true
end
if cond then
if not v:GetAttribute("Alarming") then
v:SetAttribute("Alarming", true)
effects:FireAllClients("AlarmingOn", v)
end
if AlarmedAmount.Value < 100 and not v:GetAttribute("Alarmed") then
print("up")
AlarmedAmount.Value += 1
elseif not v:GetAttribute("Alarmed") then
-- NPC gets alarmed because alarmedamount reaches 100 which is the max value
v:SetAttribute("Alarming", false)
AlarmedAmount.Value = 0
v:SetAttribute("Alarmed", true)
effects:FireAllClients("AlarmingOff", v)
effects:FireAllClients("Alarmed", v)
end
else
print(cond)
if AlarmedAmount.Value > 0 then
AlarmedAmount.Value -= 1
print("down")
else
effects:FireAllClients("AlarmingOff", v)
if v:GetAttribute("Alarming") then
v:SetAttribute("Alarming", false)
end
end
end
Basically one time the stepped event happens cond is true and it does all the stuff it should do when cond is true, but then the next time the stepped event happens, cond is false and so on.
I’ve narrowed it down to Inventory.Equipped.Value starts as “Knife” which is what it should be then it goes to nil on the next event then back to knife on the next event i dont know why because im not changing it in another script