I'm trying to make a Blocking script, any ideas?
✓ ANSWER ACCEPTED
Is there a way to reduce the amount of damage taken done by the TakeDamage method?
1 answer
✓ Accepted answer
From your blocking script, you can check if the player/NPC the weapon attacks, has a shield / whatever your game utilizes to block, and deal less damage. For example:
This is a Script (server) inside a sword.
local debounce = false
script.Parent.Blade.Touched:Connect(function(part)
if not debounce then
debounce = true
local sh = part.Parent:FindFirstChild(“Shield”)
if not sh and part.Parent ~= script.Parent.Parent then
sh.Parent.Humanoid:TakeDamage(25)
elseif sh and part.Parent ~= script.Parent.Parent then
sh.Parent.Humanoid:TakeDamage(10)
end
wait(2)
debounce = false
end
end)
I didn’t event check for a humanoid, since if a player equips the shield, their character obviously will have a humanoid. If an NPC equips it, the NPC needs a humanoid to do so, so it will have a humanoid and needs one to work. I also made sure the player can’t self inflict damage. Hope this helps.
This discussion is preserved as it was. New answers, comments, and votes are closed.
