0

# Why won't the ball spawn at all when the brick is clicked?

Hi, so I'm trying to make an automatic ball spawner at a certain position when the bricked is clicked, and after the brick is clicked twice the script is disabled. The ball for some reason isn't spawning, but it is printing Hi to show that the clicking is working. Is there something wrong with the cloning? Please help, I tried almost everything.

head = game.Workspace.corner.PRESS_ME.Head
clicked = false

print("HI")
if click == false then
click = true
while click == true do
BC.Parent = game.Workspace.corner.Spawner
BC.Handle.Position = Vector3.new(-7.8, 14.2, 31.6)
wait(5)

end
end
end)

if click == true then
click = false
end
end)


0

Take out the while loop, keep the debounce. After it is clicked, make click true, then wait until that wait(5) past, then make click false again. Try that.

0

You have:

    if click == false then
click = true
while click == true do


First off, I dont understand why you have "while click == true do" simply put, the loop will never end. You turned it to true before entering the loop, and you have no way out. at the end of the code, in line 13, add something like this:

click = false


That means that the clone will be first put in, and then once it is in every time the thing is clicked, it will be teleported back to the first spot. I dont see the point of the code at line 20-24. If you wanted it to work only twice, then you'll have to change it up a bit.

head.ClickDetector.MouseClick:connect(function()
if click == false then
click = true
if click == true then
BC.Parent = game.Workspace.corner.Spawner
BC.Handle.Position = Vector3.new(-7.8, 14.2, 31.6)
click=false
wait(5)