You left your "activated" variable to false, making the sword not work. Since I have no clue how you set up your sword, you have to edit some stuff in the code provided, especially the "-- Edit this." ones.
The Tool object has an "Activated" event to which you could connect your function.
Also, your sword's Handle (wherever it may be) has a Touched event. Your "OnTouch" function must be connected to it.
I added an extra function that listens to the Sword's Activated event, with a 1-second wait (you may change the function to however you want, as long as the "activated" variable is enabled then disabled.)
readykill = true
ready = true
activated = false
local Tool = script.Parent
local function Activate()
if not activated then
activated = true
wait(1)
activated = false
end
end
local function OnTouch(other)
if activated and readykill then
local human = other.Parent:FindFirstChild("Humanoid")
if not human then
return
end
if human.Parent == Tool then
return
end
human:TakeDamage(script.Parent.dmg.Value)
readykill = false
wait(script.Parent.Delay.Value)
readykill = true
else
print("not ready")
end
end
Tool.Touched:Connect(OnTouch)
script.Parent.Parent.Activated:Connect(Activate)
Let me know if there are problems with my solution.
1 comment
copy this game here is all instruction i think https://www.roblox.com/games/8528166735/hello