Handcuff Script not working. Please help

Hello! I am currently making a handcuff system. However, there is a area in the code that doesn’t run.


The Code:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local proxPrompt = Instance.new("ProximityPrompt")
		proxPrompt.Parent = char.HumanoidRootPart
		proxPrompt.Enabled = false
		proxPrompt.ActionText = "Arrest"
		proxPrompt.ObjectText = plr.Name
		proxPrompt.Name = "ArrestPlayer"
		proxPrompt.RequiresLineOfSight = false
		proxPrompt.HoldDuration = 0.5
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://6616249114"
		anim.Parent = char
		local animator = Instance.new("Animator")
		animator.Parent = char.Humanoid
		proxPrompt.Triggered:Connect(function(playerWhoIsArresting)
			local arrestedPlr = game.Players:GetPlayerFromCharacter(char)
			if arrestedPlr.Team.Name == "Criminal" then
				playerWhoIsArresting.leaderstats.Money.Value += arrestedPlr:GetAttribute("Bounty")

Anything below doesn’t run at all with no errors.

				game.ReplicatedStorage.BottomMessage:FireClient(playerWhoIsArresting, "You have successfully arrested ".. arrestedPlr.. ", and obtained their bounty of ".. arrestedPlr:GetAttribute("Bounty").."!")
				arrestedPlr:SetAttribute("Bounty", 0)
				arrestedPlr:SetAttribute("CanRun", false)
				game.ReplicatedStorage.BottomMessage:FireClient(arrestedPlr, "You have been arrested by ".. playerWhoIsArresting.. ". You will be sent to prison shortly." )
				char.Humanoid.WalkSpeed = 0
				local finalAnimation = animator:LoadAnimation(anim)
				finalAnimation:Play()
				for i, v in pairs(arrestedPlr.Backpack:GetChildren()) do
					v:Destroy()
				end
				wait(10)
				char:SetPrimaryPartCFrame(workspace.Spawns.PrisionSpawn.CFrame)
				finalAnimation:Stop()
				arrestedPlr:SetAttribute("CanRun", true)
				char.Humanoid.WalkSpeed = 16
			else
				playerWhoIsArresting:Kick("You have been kicked for violating the WEstudios Terms of Service. Exploiting is not allowed. If you believe this is a bug, please contact a developer with this error message.")
			end
		end)
	end)
end)

I tried making everything into a function, but that didn’t work.

If you can help, please let me know. Thanks! WE

1 Like

What exactly is the issue? You need to be specific.

I have a line in there that says

Inside the code.

game.ReplicatedStorage.BottomMessage:FireClient(playerWhoIsArresting, "You have successfully arrested ".. arrestedPlr.. ", and obtained their bounty of ".. arrestedPlr:GetAttribute("Bounty").."!")

Found out that there is a problem with this line. It finally errored.

Sorry for bumping.

I used an instance, and not a string. Just needed to add .Name

("You have been arrested by %s. You will be sent to prison shortly"):format(tostring(playerWhoIsArresting))
("You have successfully arrested %s, and obtained their bounty of %s!"):format(tostring(arrestedPlr), tostring(arrestedPlr:GetAttribute("Bounty")))