This is a server script that controls the visualizer. It works in studio, but in a server it only plays the music. Help ?

local visualizer = script.Parent.Parent
local div = script.base_divisor.Value
local song = nil
local songInfoGui = visualizer.box.songPlaying.SurfaceGui

function pickSong()
	math.randomseed(tick()*math.random()) math.random()
	song = visualizer.list.emit:GetChildren()[math.random(#visualizer.list.emit:GetChildren())]
end

function main()
	pickSong()
	song:Play()
	local Asset = game:GetService("MarketplaceService"):GetProductInfo(string.sub(song.SoundId, 14))
	songInfoGui.songName.Text = "Playing : " .. Asset.Name
	while song.Playing do
		songInfoGui.songTime.Text = math.floor(song.TimeLength - song.TimePosition)
		for _, part in pairs(visualizer.p:GetChildren()) do
			local PartPosition = part.Position
			part.Size = Vector3.new(part.Size.X, (song.PlaybackLoudness/div)/(part.num.Value), part.Size.Z)
			part.CFrame = CFrame.new(PartPosition)
			part.Color = Color3.fromHSV(part.Size.Y*2,part.Size.Y*2,part.Size.Y*2)
		end
		wait()
	end
	main()
end

main()

2 comments

0

You will need to use the run service for this kind of task.

0

How do you do that ? If you know how to, post the fixed version of the script please.