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

Im trying to change brick color but it wont work but I dont know why?

Asked by 5 years ago

Im trying to make a brick change the color is the playbackloudness is on a specific number but i keep getting this error:

Workspace.Part.Script:2: attempt to call a userdata value

The script is (its all written in a normal script):

    if workspace.Sound.IsPlaying then
script.Parent.BrickColor = BrickColor.Random()((workspace.Sound.PlaybackLoudness/1000)*5)
    end

Thank you for reading. -Jamielelystad

0
well, here is a thing to put in consideration... for some reason when you ready sound.PlaybackLoudness from a server script, it returns 0.. but it should return correct value if u read it from client User#23252 26 — 5y

1 answer

Log in to vote
0
Answered by
BuDeep 214 Moderation Voter
5 years ago
Edited 5 years ago

Your issue wasn't with the BrickColor, but rather with the way you structured your PlaybackLoudness adjustment.

Whenever you're trying to change a value such as Volume or PlaybackLoudness, if you want to adjust the original value rather than change it to a whole new number, you need to restate it, then perform your arithmetics. The below is an example of what I mean:

if workspace.Sound.IsPlaying == true then
script.Parent.BrickColor = BrickColor.Random()
workspace.Sound.Volume= (workspace.Sound.Volume/1000) * 5
end
0
Its not doing anything jamielelystad 20 — 5y
0
^ Anything in your output? BuDeep 214 — 5y
0
No jamielelystad 20 — 5y
0
You cant set PlaybackLoudness as its a ROBLOX Locked value. Since you didn't get anything in your output, either the sound was not playing or your script is disabled. I optimized the code above to work with volume rather than playback. BuDeep 214 — 5y
0
I'll try again jamielelystad 20 — 5y
Ad

Answer this question