idk what I coulda gotten wrong
local mobnumb = game.ServerScriptService.DeathCheck.MobNumber wait(5) if script.Parent.Health == 0 then wait(0.1) script.Parent.Parent:Destroy() mobnumb.Value -= 1 end
I'm guessing your NPCs use humanoids so you can used the .Died event.
A script in the NPC:
local npc = script.Parent local humanoid = npc:FindFirstChildOfClass("Humanoid") local mobNum = game.ServerScriptService.DeathCheck.MobNumber humanoid.Died:Connect(function() mobNum.Value -= 1 task.wait(0.1) npc:Destroy() end)
The issue with the value not being subtracted one is that I'm assuming you're attempting to access a local variable within DeathCheck that is only local to that script. So pretty much you're minusing one from nothing. A way I use whenever I want to have a value from a script able to be changed by anyone is by creating a folder within the player
Example:
game.Player.Playeradded:Connect(function() local folder = instance.new("Folder", player) folder.name = "Whatever" local mobnumb = instance.new("NumberValue", whatever) mobnumb.Name = "mobnumb" mobnumb.Value = 100 end)
whenever you want to minus it
player.Whatever.mobnumb.Value -=1
for the destroying part I'd have to see what you're attempting to destroy