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

This even won't fire?

Asked by 11 years ago

I've got this tool going that I retrofitted from a HopperBin. In theory, and by all known laws of RBX.Lua, this script should work, unless I'm overlooking something. The script is below; I've done my best to document it.

01s = false --This tells if the tool is selected, used to stop updatePos()
02 
03function onSelected(mouse) --Should fire when mouse is selected
04    print ("selected")
05    s = true --Indicates that the mouse is selected
06    t = Instance.new("Part") --From here until line 15 it makes the part
07    t.Anchored = true
08    t.FormFactor = 2
09    t.BottomSurface = "Smooth"
10    t.TopSurface = "Smooth"
11    t.BrickColor = BrickColor.new(Color3.new(math.random(0,1), math.random(0,1), math.random(0,1)))
12    t.Transparency = 0.3
13    t.Position = mouse.Hit.p --This is corrected in updatePos()
14    t.Size = Vector3.new(4, 0.2, 4)
15    t.Parent = game.Workspace
View all 30 lines...

This script (in HopperBin form) worked exactly as it was supposed to. There are no errors thrown with this, and nothing from here appears in the output.

3 answers

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
11 years ago

Tools require a "Handle" part (a Part named Handle parented inside the tool) in order to work (apparently).

I just tested; the script runs fine if you have the handle, and does nothing if you do not. This is probably the problem and absolutely is poor behavior on ROBLOX's part.

This is an irrelevant suggestion, but I suggest that you round the position rather than use ceiling, so that the part ends up more centered!

0
Worked! Thanks! cheweydog 20 — 11y
Ad
Log in to vote
0
Answered by 11 years ago

Since the script is in a HopperBin, these events won't work:

1script.Parent.Equipped:connect(onSelected)
2script.Parent.Unequipped:connect(onDeselected)

Those events only correspond to Tools. Tools aren't HopperBins. They're two completely seperate things. The only similarity is that both are in the backpack. The correct events to use are these:

1script.Parent.Selected:connect(onSelected)
2script.Parent.Deselected:connect(onDeselected)

I hope this helped!

*Note: For more information on HopperBins, click here: HopperBins

Log in to vote
-2
Answered by
Asirix 15
11 years ago

Try getting rid of "s = false" at the beginning?

Also, I'm not sure, but aren't you suppose to indicate what "mouse" is?

Answer this question