Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --//Local Script
- local last = 0
- local cooldown = 1
- local swinging = script.Parent:WaitForChild("Swinging")
- local canbekilled = script.Parent.CanBeKilled
- script.Parent.Equipped:Connect(function(t)
- t.Button1Down:Connect(function()
- if tick() - last > cooldown then
- last = tick()
- local a = script.Parent.Animation
- local plr = game.Players.LocalPlayer
- local char = plr.Character
- local hum = char:FindFirstChild("Humanoid")
- local animation = hum:LoadAnimation(a)
- canbekilled:FireServer(swinging, cooldown, last)
- animation:Play()
- end
- end)
- end)
- --//Server Script
- script.Parent.Parent.CanBeKilled.OnServerEvent:Connect(function(player, swinging)
- swinging.Value = true
- local last = 0
- local cooldown = 2
- script.Parent.Parent.Equipped:Connect(function()
- local tool = script.Parent.Parent
- local char = tool.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- print(plr.Name.." has equipped"..tool.Name)
- script.Parent.Touched:Connect(function(hitbox)
- if tick() - last > cooldown then
- last = tick()
- if swinging.Value == true then
- if hitbox.name == "HitBox" then
- local hum = hitbox.Parent:FindFirstChild("Humanoid")
- hum.Health = 0
- print("Kill Enabled")
- end
- end
- end
- end)
- end)
- end)
- while wait(2) do
- local swinging = script.Parent.Parent.Swinging
- swinging.Value = false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement