Advertisement
HowToRoblox

MurdererClient

Nov 18th, 2022 (edited)
2,466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. local tool = script.Parent
  2.  
  3. local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
  4. local humanoid = char.Humanoid
  5.  
  6. local stabAnim = humanoid:WaitForChild("Animator"):LoadAnimation(script:WaitForChild("StabAnimation"))
  7. local throwAnim = humanoid:WaitForChild("Animator"):LoadAnimation(script:WaitForChild("ThrowAnimation"))
  8.  
  9. local cam = workspace.CurrentCamera
  10. local mouse = game.Players.LocalPlayer:GetMouse()
  11.  
  12. local rs = game.ReplicatedStorage:WaitForChild("MurderMysteryReplicatedStorage")
  13. local config = require(rs:WaitForChild("CONFIGURATION"))
  14. local re = rs:WaitForChild("RemoteEvent")
  15.  
  16. local equipped = false
  17. local onCooldown = false
  18.  
  19. local buttonPressed = nil
  20.  
  21.  
  22. tool.Equipped:Connect(function()
  23.     equipped = true
  24. end)
  25. tool.Unequipped:Connect(function()
  26.     equipped = false
  27. end)
  28.  
  29.  
  30. mouse.Button1Down:Connect(function()
  31.     mouse.TargetFilter = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
  32.    
  33.     if not onCooldown and equipped then
  34.         buttonPressed = tick()
  35.     end
  36. end)
  37.  
  38. mouse.Button1Up:Connect(function()
  39.    
  40.     if not onCooldown and equipped and buttonPressed then
  41.         onCooldown = true
  42.        
  43.         if tick() - buttonPressed < config.MurdererWeaponHoldToThrowDuration then
  44.             re:FireServer("MURDERER STAB", tool)
  45.             stabAnim:Play()
  46.            
  47.         elseif buttonPressed and tick() - buttonPressed >= config.MurdererWeaponHoldToThrowDuration then
  48.  
  49.             re:FireServer("MURDERER THROW", tool, cam.CFrame, mouse.Hit)
  50.            
  51.             throwAnim:Play()
  52.         end
  53.        
  54.         buttonPressed = nil
  55.        
  56.         task.wait(config.MurdererWeaponCooldown)
  57.         onCooldown = false
  58.     end
  59. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement