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

Help me fix a simple recoloring script?

--I'm trying to create a script that will allow me to recolor a lot of parts, meshes, and unions within a model. I'm very amateur at scripting and could anyone help me fix this script?

Here's my code. Chest is the name of the model.

if game.Workspace.Chest.Child.BrickColor = ('Dark stone grey') then BrickColor = ('Hot pink')

Output says Workspace.Script:1: 'then' expected near '='

Would appreciate any help.

2 comments

0

pls use code block

0

= is an assignment operator. == is the comparison logic operator. The error is explaining it expected then aftern the logic but got an assignment operator.

1 answer

✓ Accepted answer

General Practice

Use workspace instead of game.Workspace

Use :WaitForChild() to make sure something exists before using or changing it

Issues

For if-then statements, if you want to make sure a property equals an assigned property, you need to make sure you use two equal signs ("==" instead of "=") since otherwise you are trying to assign a property, rather than comparing them

When you need to check a BrickColor, you must use BrickColor.new() before the name of the color since BrickColor is a type of property, not a string value.

Revised Code

if workspace:WaitForChild("Chest"):WaitForChild("Child").BrickColor == BrickColor.new("Dark stone grey") then
    BrickColor = BrickColor.new("Hot pink")

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