This code is only working in studio mode:

repeat wait() until workspace.ServerFunctions.InteractiveParts.AudioBars wait(1)
-- HEARTBEAT RENDERING
	game:GetService("RunService").Heartbeat:connect(function(step)
		local AudioBars = script.Parent.AudioBars:GetChildren()
		for i = 1, #AudioBars do
			local Visual = AudioBars[i].BackVisual.SurfaceGui.AudioVisual
			local Audio = workspace.ServerFunctions.ServerSound.ServerMusic
			
			--
			
			local BarLeft1 = (Audio.PlaybackLoudness / 22)
			if BarLeft1 <= 50 * 2 then
				Visual.BarLeft1.Size = UDim2.new(0.1,0,0,BarLeft1)
			else
				Visual.BarLeft1.Size = UDim2.new(0.1,0,0,100)
			end
			
			local BarLeft2 = (Audio.PlaybackLoudness / 11)
			if BarLeft2 <= 50 * 2 then
				Visual.BarLeft2.Size = UDim2.new(0.1,0,0,BarLeft2)
			else
				Visual.BarLeft2.Size = UDim2.new(0.1,0,0,100)
			end
			
			local BarMid = (Audio.PlaybackLoudness / 5)
			if BarMid <= 50 * 2 then
				Visual.BarMid.Size = UDim2.new(0.1,0,0,BarMid)
			else
				Visual.BarMid.Size = UDim2.new(0.1,0,0,100)
			end
			
			local BarRight1 = (Audio.PlaybackLoudness / 8)
			if BarRight1 <= 50 * 2 then
				Visual.BarRight1.Size = UDim2.new(0.1,0,0,BarRight1)
			else
				Visual.BarRight1.Size = UDim2.new(0.1,0,0,100)
			end
			
			local BarRight2 = (Audio.PlaybackLoudness / 26)
			if BarRight2 <= 50 * 2 then
				Visual.BarRight2.Size = UDim2.new(0.1,0,0,BarRight2)
			else
				Visual.BarRight2.Size = UDim2.new(0.1,0,0,100)
			end
		end
	end)
--

This is inside a ServerScript, It's suppose to be keeping the SurfaceGui's in sync. What am I doing wrong?

3 comments

0

Once again.. Is this running locally? Heartbeat is a LOCAL value. Its roughly = to the players frames per second.

0

While in studio, you are running the server in the client. So most things that depend on local/global will work until it gets online. I would personally just make the event fire when the time in workspace changes. That way it is uniform and not local..

0

The wiki says to put it inside a "Script" - not a LocalScript. Also, I tried using "while true do", and this wouldn't even work, only in studio. http://wiki.roblox.com/index.php?title=API:Class/RunService/Heartbeat