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.

7 comments

0

I love swords, and it hurts me to see a sword not corresponding to your wishes. You have my condolences, fellow writer.

0

FE = filtering enabled

0

indent please

0

^

0

you know you don't need events to build a sword right? You are using very hard scripting methods.

0

I know, i'm very bad at scripting, i'm trying to get better but all videos are outdated and I do better watching videos since i'm more of a visual learner.

0

If you have a good method for me to try and get myself on my feet and actually understand scripting a bit more, please tell me.