Ok so my sword wont do any damage or swing or anything and my character is holding the sword in the middle.
local tool = script.Parent
local function onTouch(partOther)
local humanOther = partOther.Parent:FindFirstChild("Humaniod")
if not humanOther then return end
if humanOther.Parent == tool then return end
humanOther:TakeDamage(50)
end
local function slash()
local str = Instance.new("StringValue")
str.Name = "Toolanim"
str.Value = "Slash"
str.Parent = tool
end
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
local tool = script.Parent
local handle = tool.Handle
local owner = tool.Parent
local debris = game:GetService("Debris")
local alreadyused = false
local alreadyhit = false
function onTouch(hit)
if alreadyhit == false then
alreadyhit = true
if not hit.Parent then return end
if hit.Parent == tool then return end
if hit.Parent.ClassName ~= "Humanoid" then
hit.Parent.Humanoid:TakeDamage(50)
end
end
end
function slash()
if alreadyused == false then
alreadyused = true
handle.Touched:Connect(onTouch)
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Slash"
Anim.Parent = tool
debris:AddItem(Anim,0.1) -- Now it doesnt make any lag.
wait(0.5) --change this if u want to
alreadyused = false
alreadyhit = false
end
end
tool.Activated:Connect(slash)