Below is a script that is supposed to fire the dest event once the ore durability is 0
if dur.Value-Damage <= 0 then
updateBar(Maxdur.Value, Maxdur.Value, false)
game.ReplicatedStorage.Mining.sound:FireServer(sound)
game.ReplicatedStorage.Mining.sound:FireServer(sound2)
game.ReplicatedStorage.Mining.drop:FireServer(Tar, despawnTime)
game.ReplicatedStorage.Mining.dest:FireServer(Tar)
Below is a script that destroys the target ore once the dest event is triggered and everything works fine up to this point.
game.ReplicatedStorage.Mining.dest.OnServerEvent:Connect(function(plr, tar)
tar:Destroy()
end)
The last script is meant to subtract one from the total ore count, but for some reason, the dest event happens multiple times and it changes the amount of times triggered for every ore that is destroyed. This screws up the total ore count and breaks the game.
game.ReplicatedStorage.Mining.dest.OnServerEvent:Connect (function()
OreCount = OreCount -1
end)
I think I did what you meant...
local fired = false
if dur.Value-Damage <= 0 and not fired then
updateBar(Maxdur.Value, Maxdur.Value, false)
game.ReplicatedStorage.Mining.sound:FireServer(sound)
game.ReplicatedStorage.Mining.sound:FireServer(sound2)
game.ReplicatedStorage.Mining.drop:FireServer(Tar, despawnTime)
game.ReplicatedStorage.Mining.dest:FireServer(Tar)
fired = true
There are nor errors and it still doesn't work
