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

How do I make a script in HopperBin Tool-compatible?

Just as the topic says.

The HopperBin is supposed to spawn a model where the player clicks.

This said HopperBin is composed of a Script and the said Model.

The Script is following:

bin = script.Parent

function onButton1Down(mouse)

	local model = bin.Grenade:clone()

	model.Parent = game.Workspace
	model:MakeJoints()
	model:MoveTo(mouse.hit.p)

end

function onSelected(mouse)
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

bin.Selected:connect(onSelected)

It works properly in HopperBin. However, when I put the Script and the Model in a tool, it does nothing when I click on the ground.

I tried to also add a handle, but it made only to spawn the Model somewhere on the map regardless if I click or not. It just spawns after I equip this tool.

The issue and question is: How do I make this script tool-compatible? I really wish to make the player have a Handle in their hand and spawn a proper Model in the Workspace.

The Model does not have to be in the tool. This Script also worked in HopperBin when the Model was in ServerStorage.

Best regards.

2 comments

0

HopperBins are deprecated. Do not use them for new work.

0

I know, but this HopperBin is what I found to be the greatest to perform the function of placing models. I just wish to make it a Tool, so the character will hold a Handle and other bricks.

1 answer

✓ Accepted answer
tool = script.Parent

function onButton1Down(mouse)
	
	local model = tool.Grenade:clone()
	
	model.Parent = game.Workspace
	model:MakeJoints()
	model:MoveTo(mouse.hit.p)
end

function onEquipped(mouse)
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

tool.Equipped:connect(onEquipped)

3 comments

0

You didn't fix the deprecated code.

0

It does not work.

0

What does "to deprecate" mean?

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