What I am trying to achieve and what I have already: So, what I am trying to achieve is making a part on my car that I have made, change color when the song playing in the cars stereo gets to a certain point of PlaybackLoudness. I have already made the script, and it works fine in studio, but when I upload the game it doesn't work in the game, and this is where I am having my problem.
The script: So, I have created this script; I know it is very messy and unorganized; inefficient too. But, I am still new still to scripting.
local G = script.Parent.G local Speaker,S1,S2 = script.Parent, script.Parent.Speaker1.Color1, script.Parent.Speaker2.Color2 S1.Parent, S2.Parent = G, G local Sound = script.Parent.Parent.Parent["MUSIC PLAYER"]:FindFirstChild("Sound") local L1 = Instance.new("SurfaceLight",S1) L1.Angle,L1.Range,L1.Brightness = "90", "15", "10" L1.Face = "Top" local L2 = Instance.new("SurfaceLight",S2) L2.Angle,L2.Range,L2.Brightness = "90", "15", "10" L2.Face = "Top" spawn(function() while wait() do for _,v in pairs(G:GetChildren()) do if Sound.PlaybackLoudness > 200 then v.BrickColor = BrickColor.new("Electric blue") L1.Color = Color3.new(9/255,137/255,207/255) L2.Color = Color3.new(9/255,137/255,207/255) elseif Sound.PlaybackLoudness < 200 then v.BrickColor = BrickColor.new("Really black") L1.Color = Color3.new(0,0,0) L2.Color = Color3.new(0,0,0) end end end end)
Side notes: I know this works, because It works in studio. Also, there is no errors in the developer console when I join the game, or play music in the car.