Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Why won't my water fountain work?

Asked by 10 years ago
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.

0
Put your code in a code block, to make it easier to read. MrFlimsy 345 — 10y
0
It's in a code block now. That1GuyAidan 4 — 10y
0
What is "script.Parent.brick1to20"? It appears as if you are trying to use an object as a variable. MrFlimsy 345 — 10y

2 answers

Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
10 years ago
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.

0
Thank you so much! That1GuyAidan 4 — 10y
0
This May not work though, If it doesnt work PM me Ill try to figure it out. IcyEvil 260 — 10y
Ad
Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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.

Answer this question