while true do wait(0.1) if game.StarterGui.music.MainFrame.PBL.Text = "PlayBackLoudness:10" script.Parent.BrickColor = BrickColor.Random() end end
I have no idea why I can't do "=" in the script If I was able to do that then it should've been possible to change the color Please help?
Hello it seems you are trying to change the color of a part with a script in workspace according to the Gui's text, so unless it was initially "PlayBackLoudness:10"
it would change the brickcolor. So what I suggest is you put that script in a localscript in the Gui and get the part from the workspace instead.
something like this:
local the_part = workspace:FindFirstChild("nameofpart") while true do wait(0.1) if script.Parent.music.MainFrame.PBL.Text == "PlayBackLoudness:10" then the_part.BrickColor = BrickColor.Random() end end
The reason why that won't work is because the Gui in StarterGui will not change from how you initialized it, it only gets cloned to the players. When players enter the game they have their own "folders" under the Players section where the Guis in StarterGui gets cloned to their PlayerGui. So if you want interaction between the workspace and the Gui, most preferably you use a localscript because the localscript run for each player. So in this case, a localscript running in each player's Gui
while true do wait(0.1) if game.StarterGui.music.MainFrame.PBL.Text == "PlayBackLoudness:10" then script.Parent.BrickColor = BrickColor.Random() end end
Everytime it has the 'if' You have to add a 'then' to the end of the line