Settings Volume Updater

I’m working on a Settings GUI where the player can hold click and move the mouse on the slider to change the volume of sounds. I coded so whenever the player moves one of the sliders, a NumberValue in workspace will be changed to the corresponding value. What happens is that whenever a mob spawns, I want the volume of the sound to be the value in the NumberValue of Workspace. (Sound is in HumanoidRootPart)

  1. How can I make it so it updates every time using a “Repeat Until”? (I made one with while true do but idk if it will cause a server overload/lag whenever there are a lot of mobs)

  2. I made a script but whenever the mob spawns, the script does not work for some reason.

LocalScript inside of the mob’s HumanoidRootPart;

local value = game.Workspace.Val.Value
local HRP = script.Parent

while true do
	wait(1)
	print("1")
	for i, v in pairs(HRP:GetChildren()) do
		print("2")
		if v:IsA("Sound") then
			print("3")
			print("Sound name is: ", v)
			while true do
				wait(1)
				v.Volume = value
			end
		end
	end
end

2 Likes

Hey bud! I’m sure that problem is local script cannot run while being in the workspace. So it will not run. Local script will only run if it’s located in specific directory, which is listed in this documentation.

2 Likes

Ahh, that makes more sense, thanks. I fixed it by making the script in StarterPlayerScripts :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.