hey guys,

i've been working on a sword recently with animations (idle and attack animations)

the sword has a script, a local script (with 2 animations stored in the local script) and a boolValue 'CanDamage' set to false

I don't get any errors in my output and the sword does no damage and doesn't play any animations here is my local script





local CanAttack = true
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait(5)
game.Players.LocalPlayer.Character.Archivable = true
    local idle = game.Players.LocalPlayer.Character:WaitForChild('Humanoid'):LoadAnimation(script.Idle)
local attack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Attack)

script.Parent.Equipped:Connect(function()
    
    idle:Play()    
end)

 local idle = game.Players.LocalPlayer.Character:WaitForChild('Humanoid'):LoadAnimation(script.Idle)
local attack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Attack)
   
script.Parent.Activated:Connect(function()
    
    if CanAttack == true then
        attack:Play()
        idle:Stop()
        CanAttack = false
        wait (1)
        attack:Stop()
        idle:Play()
        CanAttack= true
        script.Parent.CanDamage.Value = true
    end
end)


and here is the script


script.Parent.Blade.Touched:Connect(function(p)
    if script.Parent.CanDamage.Value == true then
        script.Parent.CanDamage.Value = false
        p.Parent.Humanoid:TakeDamage(20)
    end
end)

2 comments

0

I think you will need to use RemoteEvents because CanDamage.Value is true on the client (LocalScript) but not on the server (Script). You should fire the RemoteEvent at the client and let the server listen for the server event to set the CanDamage.Value to true instead of setting it from the client. Not sure about the animations.

0

could you help me out with that? i have no idea on how to use remote events