Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't my water fountain work?

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.

3 comments

0

Put your code in a code block, to make it easier to read.

0

It's in a code block now.

0

What is "script.Parent.brick1to20"? It appears as if you are trying to use an object as a variable.

2 answers

✓ Accepted answer
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.

2 comments

0

Thank you so much!

0

This May not work though, If it doesnt work PM me Ill try to figure it out.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.