Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do check the name of what is dragged by a HopperBin?

Asked by
Azmidium 388 Moderation Voter
9 years ago

I do not understand how to script with HopperBins because all day I have been trying to make a draggable part. I am making a game where you can place a part down onto your own baseplate, but the issue is that the HopperBin can grab EVERYTHING in the game. I need to know how to make it check if the name of the part the HopperBin is grabbing is called 'Name.."Part"' (i.e. PlayerPart)

Sorry if this doesn't comply with the rules...

2 answers

Log in to vote
0
Answered by 9 years ago

There are several ways of going by this but the most simplistic way to me is to make a constraint that checks the objects name.

Example

id = "Part"
if mouse.Target.Name == id.."Part" then
    --Code in here.
end

Line 2 requires that the mouse.Target which is the object the mouse currently is pointed at has the name of the id with the end as "Part".

Ad
Log in to vote
0
Answered by 9 years ago

By default HopperBins don't do this by default, so I assume you either have the BinType set to GameTool or Grab. Those are unscriptable, and the only way to prevent the hopperbin from dragging parts is to lock them. If you want to make it special where it only drags parts with certain names, you'll have to script your own. HopperBins are on the road to being deprecated (unsupported), so you should use tools instead as well. Tools no longer require a handle to work, so they should work exactly like HopperBins if you need them to. When you script your own dragger, the easiest way would be to use the Dragger object. Here's a tutorial on that if it helps:

http://wiki.roblox.com/index.php/User:Memory_Address/Using_Dragger

Answer this question