Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- local tool = script.Parent
- local Damage = 30
- local SlashAnim = script:WaitForChild("Slash")
- local SlashAnimTrack
- local SlashSound = script:WaitForChild("SlashSound")
- local HitSound = script:WaitForChild("HitSound")
- local hitCharacters = {}
- local debounce = false
- -- tool when used
- tool.Activated:Connect(function()
- if debounce then return end
- debounce = true
- local humanoid = script.Parent.Parent.Humanoid
- if not SlashAnimTrack then SlashAnimTrack = humanoid:LoadAnimation(SlashAnim) end
- SlashAnimTrack:Play()
- task.wait(0.1)
- SlashSound:Play()
- task.wait(0.1)
- debounce = false
- end)
- tool.Blade.Touched:Connect(function(touch)
- if hitCharacters[touch.Parent] or not debounce then return end
- if touch.Parent:FindFirstChild("Humanoid") then
- touch.Parent.Humanoid:TakeDamage(Damage)
- HitSound:Play()
- hitCharacters[touch.Parent] = true
- task.wait(0.1)
- hitCharacters[touch.Parent] = nil
- end
- end)