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)
local model = bin.Heal:clone() local unk = bin.test:clone() model.Parent = game.Workspace model:MakeJoints() model:MoveTo(mouse.hit.p) unk.Parent = model unk.Disabled = false 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:
bin = script.Parent local debounce = true function onButton1Down(mouse) if debounce then debounce = false local model = bin.Heal:clone() local unk = bin.test:clone() model.Parent = game.Workspace model:MakeJoints() model:MoveTo(mouse.hit.p) unk.Parent = model unk.Disabled = false wait(20) debounce = true end end function onSelected(mouse) mouse.Icon = "rbxasset://textures\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end bin.Selected:connect(onSelected)