Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LOCALSCRIPT:
- cuffdelay = false
- grabdelay = false
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local uis = game:GetService("UserInputService")
- script.Parent.Equipped:Connect(function()
- local cuffui = script.Parent.CuffUI
- cuffui.Parent = player.PlayerGui
- cuffui.CuffCount.Text = "Cuffs: " .. script.Parent.CuffCount.Value
- script.Parent.CuffCount.Changed:Connect(function()
- cuffui.CuffCount.Text = "Cuffs: " .. script.Parent.CuffCount.Value
- end)
- uis.InputBegan:Connect(function(input, gameprocessed)
- local humanoid = mouse.Target.Parent:FindFirstChild("Humanoid")
- if not gameprocessed then
- if input.UserInputType == Enum.UserInputType.Keyboard then
- local keypressed = input.KeyCode
- if keypressed == Enum.KeyCode.F and mouse.Target then
- if (script.Parent.Parent.Torso.Position - humanoid.Parent.Torso.Position).Magnitude < 5 then
- local handcuffs = mouse.Target.Parent:FindFirstChild("Handcuffs")
- if handcuffs and grabdelay == false then
- grabdelay = true
- game.ReplicatedStorage.Events.ToolEvents.CuffGrab:FireServer(handcuffs)
- wait(2)
- grabdelay = false
- end
- end
- end
- end
- end
- end)
- script.Parent.Unequipped:Connect(function()
- cuffui.Parent = script.Parent
- end)
- end)
- script.Parent.Activated:Connect(function()
- if mouse.Target then
- local humanoid = mouse.Target.Parent:FindFirstChild("Humanoid")
- if humanoid then
- if (script.Parent.Parent.Torso.Position - humanoid.Parent.Torso.Position).Magnitude < 10 and cuffdelay == false then
- game.ReplicatedStorage.Events.ToolEvents.CuffEvent:FireServer(humanoid, script.Parent)
- cuffdelay = true
- wait(2)
- cuffdelay = false
- end
- end
- end
- end)
- SERVER SCRIPT:
- game.Players.PlayerAdded:Connect(function(player)
- player.CharacterAdded:Connect(function(character)
- character.ChildAdded:Connect(function(child)
- if child.Name == "Handcuffs" then
- local toolfolder = Instance.new("Folder", game.ServerStorage.ConfiscatedTools)
- toolfolder.Name = player.Name
- for i, v in pairs(player.Backpack:GetChildren()) do
- v.Parent = toolfolder
- end
- for i,v in pairs(game.Workspace[player.Name]:GetChildren()) do
- if v.ClassName == "Tool" then
- v.Parent = toolfolder
- end
- end
- local anim = Instance.new("Animation", child)
- anim.AnimationId = "rbxassetid://3788265449"
- local charanim = character.Humanoid:LoadAnimation(anim)
- charanim:Play()
- child.Changed:Connect(function()
- if child.Value == "" then
- local possiblescript = child:FindFirstChild("GrabScript")
- if possiblescript then
- possiblescript:Destroy()
- end
- character.Torso.Anchored = false
- character["Left Leg"].CanCollide = true
- character["Right Leg"].CanCollide = true
- character.Head.CanCollide = true
- character.Torso.CanCollide = true
- else
- local grabscript = script.GrabScript:Clone()
- grabscript.Parent = child
- grabscript.Disabled = false
- character.Torso.Anchored = true
- character["Left Leg"].CanCollide = false
- character["Right Leg"].CanCollide = false
- character.Head.CanCollide = false
- character.Torso.CanCollide = false
- end
- end)
- character.ChildRemoved:Connect(function(removedchild)
- if removedchild == child then
- charanim:Stop()
- anim:Destroy()
- character.Torso.Anchored = false
- local possiblefolder = game.ServerStorage.ConfiscatedTools:FindFirstChild(player.Name)
- if possiblefolder then
- for i, v in pairs(possiblefolder:GetChildren()) do
- v.Parent = player.Backpack
- possiblefolder:Destroy()
- end
- end
- end
- end)
- end
- end)
- end)
- end)
- game.ReplicatedStorage.Events.ToolEvents.CuffEvent.OnServerEvent:Connect(function(player, humanoid, tool)
- local cuffs = humanoid.Parent:FindFirstChild("Handcuffs")
- if cuffs then
- cuffs:Destroy()
- tool.CuffCount.Value = tool.CuffCount.Value + 1
- else
- if tool.CuffCount.Value > 0 then
- local handcuffs = Instance.new("StringValue", game.Lighting)
- handcuffs.Name = "Handcuffs"
- handcuffs.Parent = humanoid.Parent
- tool.CuffCount.Value = tool.CuffCount.Value - 1
- end
- end
- end)
- game.ReplicatedStorage.Events.ToolEvents.CuffGrab.OnServerEvent:Connect(function(player, cuffs)
- if cuffs.Value == "" then
- cuffs.Value = player.Name
- else
- cuffs.Value = ""
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement