Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Handcuffs script not working,arrest system ,Any help?

This is the handcuffs script,it needs to work ONLY when you touch a team member of the "Really Red" team.

This is the script

Line 25

local lastPlayer = nil
local Tool = script.Parent
local Sword = Tool.Handle
local debounce = false

local shield
local shieldMesh

local vCharacter

local damage = 0
local judgement

Tool.Enabled = true

Go = true

function touched(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if debounce == true then
			return
		end
			debounce = true
		if player.Teamcolor == "Really red" then
			debounce = false
			return
		end
		if player.Character.Humanoid.Health == 0 then
			debounce = false
			return
		end
		if script.Parent.On.Value == true then
			return
		end
		if player.PlayerGui:FindFirstChild("Arrest") or player.PlayerGui:FindFirstChild("Confirm") then
			return
		end
		if player.TeamColor ~= BrickColor.new("Bright violet") then
			player.Character.Humanoid.WalkSpeed = 0
			for i,v in pairs(player.Backpack:GetChildren()) do
				v:remove()
			end
			for i,v in pairs(player.Character:GetChildren()) do
				if v.className == "Tool" then
					v:remove()
				end
			end
			if player:FindFirstChild("JobValue") then
				player.JobValue.Value = 0
			end
			script.Parent.On.Value = true
			script.Parent.Confirm.Frame.Player.Value = player.Name
			script.Parent.Confirm.Frame.TextLabel.Text = "Do you want to arrest "..player.Name.."?"
			script.Parent.Confirm:clone().Parent = game.Players:GetPlayerFromCharacter(script.Parent.Parent).PlayerGui
		else
			player:SaveNumber("TimeInJail",0)
			player:SaveBoolean("inJail",false)
			if player:IsInGroup(758071) then
				player.TeamColor = BrickColor.new("Bright green")
			if player:FindFirstChild("JobValue") then
				player.JobValue.Value = 25
			end
				player:LoadCharacter()
			else
				player.TeamColor = BrickColor.new("Bright yellow")
				player:LoadCharacter()
			end
		end
		wait(1)
	end
	debounce = false
end

function tagHumanoid(humanoid, player)
	if humanoid ~= nil then 
		creatorTag = Instance.new("ObjectValue")
		creatorTag.Name = "creator"
		creatorTag.Value = player
		creatorTag.Parent = humanoid 
	end
end

function untagHumanoid(humanoid)
	if humanoid ~= nil then 
		tag = humanoid:FindFirstChild("creator")
		if tag ~= nil then 
			tag:Remove()
		end
	end
end

function onActivated()
	if Tool.Enabled == false then
		return 
	end
	Tool.Enabled = false
	vCharacter = Tool.Parent
	myTorso = vCharacter:FindFirstChild("Torso")
	if myTorso == nil then 
		return
	end
	
	wait(0.5)
	Tool.Enabled = true

end

function onEquipped()
	script.Parent.AnimateScript.Disabled = false
	print("On Equip")
	vCharacter = Tool.Parent
	Tool.Grip = CFrame.new(0, -0.5, 0.800000012, -4.37113883e-008, -1, 0, 1, -4.37113883e-008, 0, 0, 0, 1)
	while Sword:FindFirstChild("Mesh") == nil do wait() end 
	Sword.Mesh.MeshId = "http://www.roblox.com/asset/?id=88046657"
	Sword.Mesh.TextureId = "http://www.roblox.com/asset/?id=88046679" 
	torso = vCharacter:FindFirstChild("Torso")	
	if vCharacter:FindFirstChild("Shield") == nil and torso ~= nil then

	end
end

function onUnequipped()
	torso = vCharacter:FindFirstChild("Torso")
	if torso then 
		shield = vCharacter:FindFirstChild("Shield") 
		shieldWeld = torso:FindFirstChild("ShieldHolder")
	end
	if shield then shield:Remove() end
	if shieldWeld then shieldWeld:Remove() end
	
end

Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(onUnequipped)
Tool.Activated:connect(onActivated)
somanyhits = false

Sword.Touched:connect(function(hit)
	ypcall(function () touched(hit) end)
end)

2 comments

0

wht

0

This is a free model. We do not help with free models.

2 answers

player.TeamColor is a BrickColor. You are trying to compare BrickColor to a string. Use BrickColor.new("ColorName") to compare the TeamColor.

if player.TeamColor == BrickColor.new("Really red") then
	debounce = false 
	return
end

1 comment

0

oh sh, forgot about that. lmao im so dumb

if player.TeamColor == "Really red" then

ROBLOX is case-sensitive.

you wrote "Teamcolor", c should be capitalized.

3 comments

0

Oh,Thanks,I'll try xD

0

Not working.

0

accept the other person's solution, I forgot about the BrickColor.new(), i'm sorry haha

This discussion is preserved as it was. New answers, comments, and votes are closed.