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

BrickColor not chaning based on playbackloudness?

Asked by 5 years ago
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

Log in to vote
0
Answered by
yoyyo75 74
5 years ago
Edited 5 years ago

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

0
18:02:00.138 - Players.JustSxript.PlayerGui.LocalScript:4: 'then' expected near '=' JustSxript 36 — 5y
0
if script.Parent.music.MainFrame.PBL.Text >>>=<<< "PlayBackLoudness:10" The = wont work, no clue why JustSxript 36 — 5y
0
Oh yeah, sorry, I've edited it now :) just added then yoyyo75 74 — 5y
0
Woops I edited again!!! you have to use double '==' yoyyo75 74 — 5y
View all comments (4 more)
0
its the other "="xd (next to text) JustSxript 36 — 5y
0
never mind i'll accept it when it works , testing it out now. JustSxript 36 — 5y
0
if script.Parent.music.MainFrame.PBL.Text == "PlayBackLoudness:10" then wont work? yoyyo75 74 — 5y
0
thanks, its working c: JustSxript 36 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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

Answer this question