How to detect if nothing had damage taken with the :TakeDamage queue

Currently I have been looking up and down the forums and onto other websites and I really can’t find a solution to this, i’m very new to LUA. Simply, how do you detect if you remotefunction didn’t hit another humanoid?

I’ve tried using elseif and things similar but always either getting a error, tool breaks, or completely ignores the newly written code.

Here’s a modification of a melee script which I fixed up because currently I want to add a missed sound effect to this.

local func= script.Parent.punched

func.OnServerInvoke = function(plr, hum, dmg, tor)
local sound= Instance.new(“Sound”) --Takes Damage Here and Plays Audio
sound.SoundId= “rbxassetid://137579113”
game.Debris:AddItem(sound,5)
sound.Parent=tor
sound:Play()
hum.Parent.Humanoid:TakeDamage(5)
–Add missed shot Audio queue here
end

An explanation to this would be appreciated.

Thank you for your time.

1 Like