What do you want to achieve? Add just one number to value instead of multiplying it by three
What is the issue? It multiplies by three and sometimes even higher even though humanoid health is lower and meets threshold.
What solutions have you tried so far? Tried checking if humanoid is dead or not and still wouldn’t work.
Please note this is just a cropped version of the event of which it handles dealing damage and giving value.
Events.Finish.OnServerEvent:Connect(function()
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
Target:FindFirstChildOfClass("Humanoid"):TakeDamage(35)
if Target:FindFirstChild("Humanoid").Health <= 0 and Target.Values.Downed == true then
if plr then
plr.leaderstats.TIX.Value += 37 -- Both values are affected
plr.Stats.KillStreak.Value += 1 -- Both values are affected
end
end
end)
There is a debounce but that didn’t fix it either, the player could still fire the event even though the “Target” is dead causing the value to multiply.
Are you sure, that you have done the Debounce properly?
It seems, that each time it hits, it fires as you mentioned, multiple times. This could be due to the debounce you have made not working, so I’d suggest looking more at the Debounce script.
the debounce is between the damage and it uses three waits
one that is wait(0.2)
sets finishing value to true
then the main wait(1.7)
it does the damage
then finally wait(0.6)
the finishing value is set to false and the player receives the value cash.
Events.Finish.OnServerEvent:Connect(function()
local animation = game.ReplicatedStorage.Animations.Bat.Finish
local humanoid = PlayerCharacter:FindFirstChildOfClass("Humanoid")
if humanoid then
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local animtrack = animator:LoadAnimation(animation)
for _, f in pairs(workspace:GetDescendants()) do
-- rest of script (just does damage to Target)
this is the beginning of the code where do i put the debounce in?
I don’t get why you’re doing that…? If your code can actually be posted correctly and not in segments, you have a for loop inside of a server event, and then it just changes a players values in it, repeatedly.