Advertisement
darkblooood

scripting helpers

Apr 26th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. --Local Script--
  2.  
  3. local Player = game.Players.LocalPlayer
  4. local Chr = Player.Character or Player.CharacterAdded:Wait()
  5. local Mouse = Player:GetMouse()
  6. local Tool = script.Parent
  7. local Mode
  8. local Using = false
  9. local PTorso
  10. local RemoteEvent = script.Parent.RemoteEvent
  11.  
  12. if Chr:FindFirstChild'UpperTorso' then
  13. PTorso = Chr:WaitForChild("Torso")
  14. else
  15. PTorso = Chr:WaitForChild("Torso")
  16. end
  17.  
  18. Tool.Activated:Connect(function()
  19. if not Using then
  20. if Mouse.Target then
  21. RemoteEvent:FireServer('Cuff', Mouse.Target)
  22. end
  23. else
  24. Using = false
  25. RemoteEvent:FireServer('UnCuff')
  26. end
  27. end)
  28.  
  29. RemoteEvent.OnClientEvent:Connect(function( one )
  30. if one == 'Use' then
  31. Using = true
  32. end
  33. end)
  34.  
  35. --Server Script--
  36.  
  37. --Scripted by bowypenguino
  38. --BOWYSOFT
  39. local RemoteEvent = script.Parent.RemoteEvent
  40. local Using = false
  41. local TargetTorso
  42.  
  43. function CheckForChar(Part)
  44. if Part.Parent:IsA'Model' and Part.Parent:FindFirstChildOfClass'Humanoid' then
  45. local Char = Part.Parent
  46. local Torso
  47. if Char:FindFirstChild("Torso") then
  48. Torso = Char.Torso
  49. else
  50. Torso = Char.UpperTorso
  51. end
  52. TargetTorso = Torso
  53. return Char
  54. end
  55. end
  56.  
  57. function CheckForTorso(player)
  58. local Char = player.Character
  59. if Char:FindFirstChild("Torso") then
  60. return Char.Torso
  61. else
  62. return Char.UpperTorso
  63. end
  64. end
  65.  
  66. RemoteEvent.OnServerEvent:Connect(function(player, one, two)
  67. if one == 'Cuff' then
  68.  
  69. local Target = CheckForChar(two)
  70. local PlayerTorso = CheckForTorso(player)
  71.  
  72. if Target then
  73. Using = true
  74. RemoteEvent:FireClient(player, 'Use')
  75. spawn(function()
  76.  
  77. while Using and wait() do
  78. TargetTorso.Anchored = true
  79. TargetTorso.CFrame = PlayerTorso.CFrame * CFrame.new( 0, 0, -2.5 )
  80. if TargetTorso.Parent.Humanoid.Health >= 0 then
  81. TargetTorso.Cframe = true
  82. TargetTorso.CFrame = PlayerTorso.CFrame * CFrame.new( 0, 0, -2.5 )
  83. end
  84. end
  85.  
  86. end)
  87.  
  88. end
  89.  
  90. elseif one == 'UnCuff'then
  91.  
  92. Using = false
  93. wait()
  94. TargetTorso.Anchored = false
  95.  
  96. end
  97.  
  98. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement