function onClicked() while true do for i = 1, 20 do script.Parent.brick1to20 = Instance.new("Part") script.Parent.brick1to20.BrickColor = BrickColor.new("Bright blue") script.Parent.brick1to20.Transparency = 0.5 script.Parent.brick1to20.Shape = "Ball" wait(2) script.Parent.brick1to20.Name = "MyBrickNumber" .. tostring(i) script.Parent.brick1to20.Parent = game.Workspace script.Parent.brick1to20:remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked) end
It's not working for some reason. I'm trying to make it where you have to click to turn on the fountain. It does not say anything in the output and it's just plain not working.
function onClicked() while true do for i = 1, 20 do f = Instance.new("Part", game.Workspace) c = Insance.new("ClickDetector", game.Workspace.Part) -- take out if you have a click detector. f.BrickColor = BrickColor.new("Bright blue") f.Transparency = 0.5 f.Shape = "Ball" wait(2) f.Name = "MyBrickNumber" .. tostring(i) f.Parent = game.Workspace f:remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked) end
brick1to20 isnt a thing... Unless it is in workspace which would than be
game.Workspace.brick1to20
I have also made it easier for you to, just incase you didnt add a clickdetector.
Properties of objects are not variables. You cannot set script.Parent.brick1to20
.
Use a normal variable, like brick =
.
In addition, you never parent your new part, until a moment before destroying it. Its parent needs to be set prior to destroying it so that it exists in the world for some amount of time.