I was making a zombie value script for my zombie game, and for some reason it removes 3 values when dead instead of 1. Here’s the script.
local zombiesCount = (game.Workspace.serverValues.zombiesCount)
local zombieHumanoid = (script.Parent)
if zombieHumanoid then
zombiesCount.Value = (zombiesCount.Value + 1)
zombieHumanoid.Died:Connect(function()
zombiesCount.Value = (zombiesCount.Value - 1)
end)
end
local zombiesCount = (game.Workspace.serverValues.zombiesCount)
local zombieHumanoid = (script.Parent)
function removeZombieCount(removeValue)
zombiesCount.Value = zombiesCount.Value - removeValue
end
function addZombieCount(addValue)
zombiesCount.Value = zombiesCount.Value + addValue
end
if zombieHumanoid then
addZombieCount()
zombieHumanoid.Died:Connect(function()
removeZombieCount()
end)
end
It works, but still decreases by 3 everytime it dies for some reason.
local zombiesCount = (game.ServerStorage.serverValues.zombiesCount)
local zombieHumanoid = (script.Parent)
function removeZombieCount(removeValue)
wait(1)
zombiesCount.Value = zombiesCount.Value - removeValue
end
function addZombieCount(addValue)
wait(1)
zombiesCount.Value = zombiesCount.Value + addValue
end
if zombieHumanoid then
addZombieCount(1)
zombieHumanoid.Died:Connect(function()
removeZombieCount(1)
end)
end
if zombieHumanoid then
db = false
addZombieCount(1)
zombieHumanoid.Died:Connect(function()
if db == false then
db = true
removeZombieCount(1)
wait(3)
db = false
end
end)
end