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

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

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

1 comment

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

1 answer

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

5 comments

0

Its not doing anything

0

^ Anything in your output?

0

No

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.

0

I'll try again

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