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

How To Make all things in Workspace Change color? [closed]

Asked by
IcyEvil 260 Moderation Voter
10 years ago

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.

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?

2 answers

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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);
0
This Really had not helped me much But thank you for the Help Much appreciated. IcyEvil 260 — 10y
Ad
Log in to vote
0
Answered by
Maxomega3 106
10 years ago

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