Hi there. So today I tried to make a wanted level script where if you shoot a cop you become wanted. I decided to use a value for the wanted level and a script that makes the value go up.
if script.Parent.Humanoid.Health == 0 then workspace.WantedStars.Value = workspace.WantedStars.Value + 1 end
Then inside the value, I added a script that detects if the value went up. If it did, then it makes the cops hostile.
if script.Parent.Value == 1 then workspace.Police1["NPC AI"].Disabled = false workspace.Police2["NPC AI"].Disabled = false workspace.Police4["NPC AI"].Disabled = false workspace.Police3["NPC AI"].Disabled = false workspace.Police5["NPC AI"].Disabled = false workspace.Police6["NPC AI"].Disabled = false workspace.Police7["NPC AI"].Disabled = false workspace.Police8["NPC AI"].Disabled = false end
Those scripts will not work like that. I am assuming this are whole scripts, right? They will only check for value once at the start of the game, and never run again.
To fix this, the easiest way would be to encapsulate them in infinite loops.
while true do if script.Parent.Humanoid.Health == 0 then workspace.WantedStars.Value = workspace.WantedStars.Value + 1 break -- I forgot the break end wait(1) --check every second end
Other script:
while true do if script.Parent.Value == 1 then workspace.Police1["NPC AI"].Disabled = false workspace.Police2["NPC AI"].Disabled = false workspace.Police4["NPC AI"].Disabled = false workspace.Police3["NPC AI"].Disabled = false workspace.Police5["NPC AI"].Disabled = false workspace.Police6["NPC AI"].Disabled = false workspace.Police7["NPC AI"].Disabled = false workspace.Police8["NPC AI"].Disabled = false end wait(1) -- check every second end
Proper way to do this however would be to add an event listener. But for beginners, this method is recommended.