This is my script, it's for killing & animating.
local CanAttack = true local sound = script.Parent.Sound script.Parent.Activated:connect(function() local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Crowbarhit2) if CanAttack == true then attack:Play() sound:Play() CanAttack = false wait(1) attack:Stop() sound:Stop() CanAttack = true> script.Parent.CanDamage.Value = true end end)
[SECOND ONE]
local sound4 = script.Parent.Sound4 script.Parent.blade.Touched:connect(function(p) if script.Parent.CanDamage.Value == true then p.Parent.Humanoid:TakeDamage(25) sound4:Play() script.Parent.CanDamage.Value = false end end)
but It works, but I don't know how to make it so no Teamkilling happens.
For this you would use the function “GetPlayerFromCharacter()” of the players service.
—blade touch local hitPlayer = game.Players:GetPlayerFromCharacter(p.Parent) canAttack = hitPlayer.Team ~= LocalPlayer.Team if canAttack then —kill script end
local sound4 = script.Parent.Sound4 script.Parent.blade.Touched:connect(function(p) local hitPlayer = game.Players:GetPlayerFromCharacter(p.Parent) canDamage = hitPlayer.Team ~= LocalPlayer.Team if canDamage then p.Parent.Humanoid:TakeDamage(25) sound4:Play() script.Parent.CanDamage.Value = false end end)
THIS IS NOT WORKING