So bascially I am making an infection game. I need to make a 3 hit infect tool so when a player gets hit 3 times they get infected. I need to tool to work threw the hands and not a sword or anything if someone can help me fix or even get me a new script that would be amazing. here is my script i am using as of right now (reds is the sprinting anim)
local can_attack = true;
local strength = 10;
function load_animation()
local player = script.Parent.Parent.Humanoid;
player:LoadAnimation(script.Idle):Play();
end
function activate()
local player = script.Parent.Parent.Humanoid;
local has_tagged = false;
local is_attacking = false;
if can_attack == false then
print("attack failed")
return
end
if can_attack == true then
is_attacking = true;
can_attack = false;
print("attack succeded")
player:LoadAnimation(script.Attack):Play();
local arm = player.Parent["Left Arm"];
arm.Touched:Connect(function(p)
if has_tagged == true then
return;
end
if has_tagged == false then
if p.Parent:FindFirstChild("Humanoid") then
has_tagged = true;
end
if p.Parent:FindFirstChild("Humanoid") then
if p.Parent.Humanoid.Health <=80 then
p.Parent.Handler.PlayAnim.Value = true;
p.Parent.Humanoid.WalkSpeed = 0;
p.Parent.reds.Disabled = true;
p.Parent.Handler.Infected.Value = true;
wait(5.5);
p.Parent.reds.Disabled = false;
p.Parent.Humanoid.WalkSpeed = 16;
p.Parent.Humanoid.Health = p.Parent.Humanoid.MaxHealth;
end
if is_attacking == true and p.Parent.Handler:FindFirstChild("Infected") and game.Players:GetPlayerFromCharacter(p.Parent).TeamColor ~= game.Teams.Infected.TeamColor then
script.Parent.Slash:Play();
local max_damage = strength + ((100 - p.Parent.Humanoid.Health) / 4);
print(max_damage)
p.Parent.Humanoid.Health -= math.random(5,max_damage);
strength = 10;
end
end
end
end)
wait(0.05);
player:LoadAnimation(script.Idle):Play();
wait(2.5)
can_attack = true;
has_tagged = false;
is_attacking = false;
end
end
script.Parent.Equipped:Connect(load_animation);
script.Parent.Activated:Connect(activate);