Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- Players = game:GetService("Players")
- Debris = game:GetService("Debris")
- InsertService = game:GetService("InsertService")
- WhackAnim = Tool:WaitForChild("Whack")
- SlashSound = Handle:WaitForChild("SlashSound")
- HitSound = Handle:WaitForChild("Hit")
- Damage = 10 --the damage dealt
- ReloadTime = 1.45 --time between each swing
- Kills = 0 --start off with 0 killstreak
- function TagHumanoid(humanoid, player) --registers you actually hitting the guy
- HitSound:Play()
- local Creator_Tag = Instance.new("ObjectValue")
- Creator_Tag.Name = "creator"
- Creator_Tag.Value = player
- Debris:AddItem(Creator_Tag, 2)
- Creator_Tag.Parent = humanoid
- end
- function UntagHumanoid(humanoid) --removes the tag so that if someone kills the person you tagged, it doesnt register you killing that person.
- for i, v in pairs(humanoid:GetChildren()) do
- if v:IsA("ObjectValue") and v.Name == "creator" then
- v:Destroy()
- end
- end
- end
- function Blow(Hit) --registers the hit, deals damage to the player, and if the humanoid has 0 health a kill is added into the killstreak.
- if Hit and Hit.Parent then
- local character = Hit.Parent
- local humanoid = character:FindFirstChild("Humanoid")
- if Humanoid and Humanoid ~= humanoid and humanoid and Humanoid.Health > 0 and humanoid.Health > 0 then
- local Right_Arm = Character:FindFirstChild("Right Arm")
- if Right_Arm then
- local Joint = Right_Arm:FindFirstChild("RightGrip")
- if (Joint and (Joint.Part0 == Handle or Joint.Part1 == Handle)) then
- humanoid:TakeDamage(Damage) --deal regular damage or instakill normal health players if a ninja
- UntagHumanoid(humanoid)
- TagHumanoid(humanoid, Player)
- end
- end
- end
- end
- end
- function Activated() --when you swing
- if Tool.Enabled then
- Tool.Enabled = false
- Whack = Humanoid:LoadAnimation(WhackAnim)
- if Whack then
- Whack:Play()
- SlashSound:Play()
- end
- wait(ReloadTime)
- Tool.Enabled = true
- end
- end
- function Equipped(mouse) --get everything settled up
- Character = Tool.Parent
- Player = Players:GetPlayerFromCharacter(Character)
- Humanoid = Character:FindFirstChild("Humanoid")
- Torso = Character:FindFirstChild("Torso")
- if not Humanoid or not Torso then
- return
- end
- if not Tool.Enabled then
- wait(ReloadTime)
- Tool.Enabled = true
- end
- end
- function Unequipped()
- if Whack then
- Whack:Stop() --stop the swing anim so we dont get stuck
- end
- end
- --important stuff to register what is what. you need these if you want to do stuff with the tool itself.
- Tool.Activated:connect(Activated)
- Tool.Equipped:connect(Equipped)
- Tool.Unequipped:connect(Unequipped)
- Handle.Touched:connect(Blow)
Advertisement
Add Comment
Please, Sign In to add comment