#adding knockback (SOLVED)
1 messages · Page 1 of 1 (latest)
local sword = script.sword
sword.Transparency = 1
local joint = script["sword joint"]
sword.Parent = script.Parent["Right Arm"]
joint.Parent = script.Parent["Right Arm"]
joint.Part0 = script.Parent["Right Arm"]
joint.Part1 = sword
script["slash event"].Parent = script.Parent
--since default has no ability, the 10th line of code is commented
--script["ability used event"].Parent = script.Parent
local slash_track = script.Parent:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"):LoadAnimation(script.slash)
script.Parent["slash event"].OnServerEvent:Connect(function()
slash_track:Play()
sword.Transparency = 0
slash_track:GetMarkerReachedSignal("slash"):Wait()
sword["sword slash"]:Play()
local hitted = {}
local can_damage = true
local function damage(hit:BasePart)
if hit.Parent:FindFirstChildOfClass("Humanoid") and not table.find(hitted, hit.Parent) and can_damage == true then
hit.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(10)
table.insert(hitted, hit.Parent)
end
end
sword.Touched:Connect(damage)
slash_track:GetMarkerReachedSignal("stop damage"):Once(function()
can_damage = false
end)
slash_track.Stopped:Wait()
sword.Transparency = 1
end)
oh i solved it