Hi everyone I’m currently working on a Tool Ability System and I want that if I press the Tool no one can damage me for 5 second and it should have a 10 seconds cooldown I tried using chat got but um…
2 Likes
Maybe try setting an attribute to the player who clicked the with the shield tool and in hitting scripts check if that player has that attribute
1 Like
You could try setting the MaxHealth and Health property of the Humanoid to math.huge, but to actually ignore damage it would be a bit more complicated. However, you could do something like this:
local canDamage = true
local duration = 5
local debounceTime = 10
local debounce = false
local health
local owner
tool.Activated:Connect(function()
owner = tool.Parent
if debounce then return end
debounce = true
health = owner.Humanoid.Health
canDamage = false
task.wait(duration)
debounce = false
end)
owner.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if canDamage == false and health then
owner.Humanoid.Health = health
end
end)
I haven’t tested it out, but something like that should work.
2 Likes
I have tried it in a Local and normal script and both didn’t really work it might be because tool was underlined blue I tried fix this with this Code: local tool = script.Parent do I have to do something(Sry if annoying but I’m not a pro:[ )
You can insert a forcefield into the character:
local FF = Instance.new("ForceField", player.Character)
game:GetService("Debris"):AddItem(FF, 5)