Script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local SwordSwingingEvent = ReplicatedStorage:WaitForChild("SwordSwingingEvent") SwordSwingingEvent.OnServerEvent:connect(function(player) script.Parent.blade.Touched:connect(function(hit) if script.Parent.CanDamage.Value == true then script.Parent.CanDamage.Value = false if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(30) wait(1) script.Parent.CanDamage.Value = true end end end) end)
Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local SwordSwingingEvent = ReplicatedStorage:WaitForChild("SwordSwingingEvent") SwordSwingingEvent:FireServer() local CanAttack = true script.Parent.Activated:connect(function() local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack) if CanAttack == true then attack:Play() CanAttack = false wait(1) attack:Stop() CanAttack = true script.Parent.CanDamage.Value = true end end)
I have a remote event in Replicated Storage labeled "SwordSwingingEvent" and I added it in hopes it would change it but i'm not that skilled with scripting so far so it didn't change anything. There is also a part on my sword labeled 'blade' which is the main part that is meant to damage the player since it covers the blade of the sword. Finally there is a BoolValue labeled CanDamage and it's set to true. I hope I added all the info I needed thank you.