How do I make a visualizer's script run in a normal script?

You can write your topic however you want, but you need to answer these questions:
Hello! So as you all know, if you want to size something depending on a sound’s playbackloudness, you’d have to do it in a local script and place the local script inside of the StarterPlayerScripts.

Now, how would I do something like this in a NORMAL script that can we placed inside of the workspace? This is what the code looks like if you don’t know what I mean by “sizing something depending on a sound’s playbackloudness”.

local VisualizerPart= -- Code Here

local Music = -- Code Here
 
local MaxLoudness = 250

while true do
	local Amplitude = math.clamp(Music.PlaybackLoudness / MaxLoudness, 0, 3.05)
	VisualizerPart.Size = Vector3.new(Amplitude, Amplitude, Amplitude)
	VisualizerPart.Color = Color3.fromRGB(Music.PlaybackLoudness/3.9,Music.PlaybackLoudness/3.9,Music.PlaybackLoudness/3.9)
	wait(0.01)
end

If I’m not mistaken, PlaybackLoudness can only be read by clients, not the server. So trying to put it in a normal script would not work as if would only return zero.

Just do all the rendering on the client, there is no reason to do anything on the server in this case.

I understand that it’s useless in this case, but I’m a serversided scripter and use modules to load scripts, for instance; UTGs, Ultimate Trolling GUIs use modules and load scripts on you or other people. If I can’t run it via a normal script, what do I do then?

Just make it as a localscript as I stated. You can play the sound on the Server, and the clients can render it for you. Its basically the same exact thing, as all clients will be rendering the same thing. Otherwise you can’t, as the server doesn’t handle music, clients do.

I’ll try and parent the localscript to the StarterPlayerScripts with the mainmodule, thank you again.

I’ve tried parenting the script to the StarterPlayerScripts with the mainmodule, the parenting worked but it didn’t do anything.

Try putting the script into the StarterGui service instead, I was having issues with my visualizer working in StarterPlayerScripts but it worked fine once I moved it into StarterGui.

I’m trying to parent it via a script, which doesn’t work. If I don’t parent it via a script but just put the localscript in a StarterGui it works, but I need to parent it with a script in my situation.

Have the script disabled before parenting, then afterwards reenable it.