Below is a small script that allows a Hopperbin to spawn a model. I'm trying to add a cooldown so that it cannot be spammed but every attempt so far has failed.
bin = script.Parent
function onButton1Down(mouse)
1 | local model = bin.Heal:clone() |
2 | local unk = bin.test:clone() |
3 |
4 | model.Parent = game.Workspace |
5 | model:MakeJoints() |
6 | model:MoveTo(mouse.hit.p) |
7 | unk.Parent = model |
8 | unk.Disabled = false |
9 | wait( 20 ) |
end function onSelected(mouse) mouse.Icon = "rbxasset://textures\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end
bin.Selected:connect(onSelected)
You just need to add a debounce:
01 | bin = script.Parent |
02 |
03 | local debounce = true |
04 | function onButton 1 Down(mouse) |
05 | if debounce then |
06 | debounce = false |
07 | local model = bin.Heal:clone() |
08 | local unk = bin.test:clone() |
09 | model.Parent = game.Workspace |
10 | model:MakeJoints() |
11 | model:MoveTo(mouse.hit.p) |
12 | unk.Parent = model |
13 | unk.Disabled = false |
14 | wait( 20 ) |
15 | debounce = true |