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

How to make the '=' button drop all hats on ground?

local uis = game:GetService("UserInputService")
local t = {}

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Equals then
		for i,v in pairs(script.Parent) do
			table.insert(t,v)
			print(t)
			print(t)
			if v:IsA("Accessory") then
		local p = Instance.new("Part",workspace)
		p.Size = Vector3.new(2,2,2)
		p.Position = Vector3.new(script.Parent.Head.Position.X,script.Parent.Head.Position.Y+4,script.Parent.Head.Position.Z)
		local h = Instance.new("MeshPart",p)
		h.MeshId = v.Handle.Mesh.MeshId
		end
		end
		end
end)

1 answer

✓ Accepted answer

http://devforum.roblox.com/t/removing-accessory-dropping-key-shortcut/31214 has info on this.

You should put this inside a local script inside the PlayerScripts folder:

local function dropHats() --drop hats function
	local localPlayer = game:GetService("Players").LocalPlayer    
	if localPlayer and localPlayer.Character then
		for _, obj in pairs(localPlayer.Character:GetChildren()) do
			if obj:IsA("Accoutrement") then
				obj.Parent = game.Workspace
			end
		end
	end
end

game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) 
	if not gameProcessedEvent then
		if inputObject.KeyCode == Enum.KeyCode.Equals then --checks if "=" is pressed
			dropHats()
		end
	end
end)

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