Advertisement
Guest User

code

a guest
Oct 13th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.41 KB | None | 0 0
  1. LOCALSCRIPT:
  2. cuffdelay = false
  3. grabdelay = false
  4. local player = game.Players.LocalPlayer
  5. local mouse = player:GetMouse()
  6. local uis = game:GetService("UserInputService")
  7. script.Parent.Equipped:Connect(function()
  8.     local cuffui = script.Parent.CuffUI
  9.     cuffui.Parent = player.PlayerGui
  10.     cuffui.CuffCount.Text = "Cuffs: " .. script.Parent.CuffCount.Value
  11.    
  12.     script.Parent.CuffCount.Changed:Connect(function()
  13.         cuffui.CuffCount.Text = "Cuffs: " .. script.Parent.CuffCount.Value
  14.     end)
  15.    
  16.     uis.InputBegan:Connect(function(input, gameprocessed)
  17.     local humanoid = mouse.Target.Parent:FindFirstChild("Humanoid")
  18.     if not gameprocessed then
  19.         if input.UserInputType == Enum.UserInputType.Keyboard then
  20.             local keypressed = input.KeyCode
  21.             if keypressed == Enum.KeyCode.F and mouse.Target then
  22.                 if (script.Parent.Parent.Torso.Position - humanoid.Parent.Torso.Position).Magnitude < 5 then
  23.                     local handcuffs = mouse.Target.Parent:FindFirstChild("Handcuffs")
  24.                     if handcuffs and grabdelay == false then
  25.                         grabdelay = true
  26.                         game.ReplicatedStorage.Events.ToolEvents.CuffGrab:FireServer(handcuffs)
  27.                         wait(2)
  28.                         grabdelay = false
  29.                     end
  30.                 end
  31.             end
  32.         end
  33.     end
  34. end)
  35.  
  36. script.Parent.Unequipped:Connect(function()
  37.         cuffui.Parent = script.Parent
  38.     end)
  39. end)
  40.  
  41. script.Parent.Activated:Connect(function()
  42.     if mouse.Target then
  43.         local humanoid = mouse.Target.Parent:FindFirstChild("Humanoid")
  44.         if humanoid then
  45.             if (script.Parent.Parent.Torso.Position - humanoid.Parent.Torso.Position).Magnitude < 10 and cuffdelay == false then
  46.                 game.ReplicatedStorage.Events.ToolEvents.CuffEvent:FireServer(humanoid, script.Parent)
  47.                 cuffdelay = true
  48.                 wait(2)
  49.                 cuffdelay = false
  50.             end
  51.         end
  52.     end
  53. end)
  54.  
  55.  
  56.  
  57.  
  58.  
  59. SERVER SCRIPT:
  60. game.Players.PlayerAdded:Connect(function(player)
  61.     player.CharacterAdded:Connect(function(character)
  62.         character.ChildAdded:Connect(function(child)
  63.             if child.Name == "Handcuffs" then
  64.                 local toolfolder = Instance.new("Folder", game.ServerStorage.ConfiscatedTools)
  65.                 toolfolder.Name = player.Name
  66.                 for i, v in pairs(player.Backpack:GetChildren()) do
  67.                     v.Parent = toolfolder
  68.                 end
  69.                 for i,v in pairs(game.Workspace[player.Name]:GetChildren()) do
  70.                     if v.ClassName == "Tool" then
  71.                         v.Parent = toolfolder
  72.                     end
  73.                 end
  74.                 local anim = Instance.new("Animation", child)
  75.                 anim.AnimationId = "rbxassetid://3788265449"
  76.                 local charanim = character.Humanoid:LoadAnimation(anim)
  77.                 charanim:Play()
  78.                 child.Changed:Connect(function()
  79.                     if child.Value == "" then
  80.                         local possiblescript = child:FindFirstChild("GrabScript")
  81.                         if possiblescript then
  82.                             possiblescript:Destroy()
  83.                         end
  84.                         character.Torso.Anchored = false
  85.                         character["Left Leg"].CanCollide = true
  86.                         character["Right Leg"].CanCollide = true
  87.                         character.Head.CanCollide = true
  88.                         character.Torso.CanCollide = true
  89.                     else
  90.                         local grabscript = script.GrabScript:Clone()
  91.                         grabscript.Parent = child
  92.                         grabscript.Disabled = false
  93.                         character.Torso.Anchored = true
  94.                         character["Left Leg"].CanCollide = false
  95.                         character["Right Leg"].CanCollide = false
  96.                         character.Head.CanCollide = false
  97.                         character.Torso.CanCollide = false
  98.                     end
  99.                 end)
  100.                 character.ChildRemoved:Connect(function(removedchild)
  101.                     if removedchild == child then
  102.                         charanim:Stop()
  103.                         anim:Destroy()
  104.                         character.Torso.Anchored = false
  105.                         local possiblefolder = game.ServerStorage.ConfiscatedTools:FindFirstChild(player.Name)
  106.                         if possiblefolder then
  107.                             for i, v in pairs(possiblefolder:GetChildren()) do
  108.                                 v.Parent = player.Backpack
  109.                                 possiblefolder:Destroy()
  110.                             end
  111.                         end
  112.                     end
  113.                 end)
  114.             end
  115.         end)
  116.     end)
  117. end)
  118.  
  119. game.ReplicatedStorage.Events.ToolEvents.CuffEvent.OnServerEvent:Connect(function(player, humanoid, tool)
  120.     local cuffs = humanoid.Parent:FindFirstChild("Handcuffs")
  121.     if cuffs then
  122.         cuffs:Destroy()
  123.         tool.CuffCount.Value = tool.CuffCount.Value + 1
  124.     else
  125.         if tool.CuffCount.Value > 0 then
  126.             local handcuffs = Instance.new("StringValue", game.Lighting)
  127.             handcuffs.Name = "Handcuffs"
  128.             handcuffs.Parent = humanoid.Parent
  129.             tool.CuffCount.Value = tool.CuffCount.Value - 1
  130.         end
  131.     end
  132. end)
  133.  
  134. game.ReplicatedStorage.Events.ToolEvents.CuffGrab.OnServerEvent:Connect(function(player, cuffs)
  135.     if cuffs.Value == "" then
  136.         cuffs.Value = player.Name
  137.     else
  138.         cuffs.Value = ""
  139.     end
  140. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement