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

Handle is not a valid member of tools?

This is my handcuff script. I can't get it to work

https://gyazo.com/97bed514de19c636db5e6be16dd88a5a


local Player = game.Players.LocalPlayer
	local inUse = false
	
	
	script.Parent.Handle.Touched:connect(function(hit)
		local HH = hit.Parent:FindFirstChild("Humanoid")
		if HH and HH.Parent ~= Player.Character then
			if not inUse then
				inUse = true
				local name = HH.Parent.Name
				local gui = script.Parent.Arrest:clone()
				gui.Parent = Player.PlayerGui
				gui.Draggable.Frame.Value.Value = name
				gui.Draggable.Frame.TextLabel.Text = "Do you wish to arrest: "..name.."?"
				gui.Draggable.Frame.Visible = true
				
					gui.Draggable.Frame.Confirm.MouseButton1Click:connect(function()
						print('Arrest',gui.Draggable.Frame.Value.Value, gui.Draggable.Frame.Reason.Text)
						inUse = false
						gui:Destroy()
					end)
		
					gui.Draggable.Frame.Cancel.MouseButton1Click:connect(function()
						inUse = false
						gui:Destroy()
					end)
			end
		end
	end)
	script.Parent.Equipped:connect(function()
		inUse = false
		Player.Character.Humanoid.WalkSpeed = 28
	end)

	script.Parent.Unequipped:connect(function()
		inUse = false
		Player.Character.Humanoid.WalkSpeed = 16
	end)

1 answer

You're using this which is not how you do a function in a local script.

script.Parent.Handle.Touched:connect(function(hit)

You should try using this.

local function Arrest()
	-- Code here
end

local function OnEquipped()
	repeat
		wait()
		if script.Parent.Handle.Touched:Connect() then
			Arrest()
		end
	until Tool.Unequipped:connect()
end

Tool.Equipped:connect(OnEquipped)

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