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

BrickColor not chaning based on playbackloudness?

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?

2 answers

✓ Accepted answer

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

8 comments

0

18:02:00.138 - Players.JustSxript.PlayerGui.LocalScript:4: 'then' expected near '='

0

if script.Parent.music.MainFrame.PBL.Text >>>=<<< "PlayBackLoudness:10" The = wont work, no clue why

0

Oh yeah, sorry, I've edited it now :) just added then

0

Woops I edited again!!! you have to use double '=='

0

its the other "="xd (next to text)

0

never mind i'll accept it when it works , testing it out now.

0

if script.Parent.music.MainFrame.PBL.Text == "PlayBackLoudness:10" then wont work?

0

thanks, its working c:

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

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