There are two parts of the script, the first part has LocalPlayer, which I just heard that it only works in studio? but this is only method of coding the animation to play that I know.
player = game.Players.LocalPlayer
repeat wait() until player.Character
character = player.Character
CanAttack = true
animation = character.Humanoid:LoadAnimation(script.Parent.AttackAnim)
script.Parent.Activated:connect(function()
if CanAttack == true then
CanAttack = false
script.Parent.Attack.Value = true
animation:Play()
wait(0.5)
CanAttack = true
script.Parent.Attack.Value = false
end
end)
The second part is just for damage, and seems to work fine.
wait(1)
CanAttack = true
script.Parent.Touched:connect(function(part)
local human = part.Parent:findFirstChild("Humanoid")
if human then
if human.Parent.Name ~= script.Parent.Parent.Parent.Name and
CanAttack == true and script.Parent.Parent.Attack.Value == true then
CanAttack = false
human:TakeDamage(10)
wait(0.5)
CanAttack = true
end
end
end)
Any help on this would be awesome. Thanks!
