I think it would be this
while true do function onClick(PlayerClicked) script.game.Workspace.BrickColor = BrickColor.random() wait(8.4) end
Im not sure though Could you please tell me if this would work, and if it doesn't why and an example on how it should be made, If you could I would Love it thank you.
The Workspace does not have a BrickColor property, so you could predict that this wouldn't work.
Instead, you need to find the objects in the Workspace.
To find all "immediate children" (the things in the workspace but not in submodels) you can use :GetChildren().
function onClick() local children = Workspace:GetChildren(); -- children is a table of objects that we iterate over. for i = 1,#children do if children[i]:IsA("BasePart") then -- Since it will error if children[i] is not a part -- (doesn't have BrickColor) we check that it is a part. children[i].BrickColor = BrickColor.random(); end end end
Your definition of the onClick function however was wrong... It should look like the above script plus one additional line like this:
SomeClickDetectorValue.MouseClick:connect(onClick);
This will not work for a number of reasons: 1) The while loop isn't necessary. 2) The .MouseClick function is also unnecessary 4) game isn't a valid child of script. game is highest part of the hierarchy. 5) Workspace does not have a BrickColor property.
Here's what you need: GetChildren() method A refresher on hierarchy
Locked by IcyEvil, BlackOrange3343, and PyccknnXakep
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?