Settings slider

I will now try @coo1ifyy’s idea and if that doesn’t work you can give the updated version

Edit: give it please, his script doesn’t work

did you set gamesound.volume to 0.5?

Yes, but you’re script doesn’t work with the saving script inside it

oh just add it back, I removed it cause its gonna break the code entirely since I don’t have datastores on and the game isnt published

so…

local toggled = true
local debounce = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RE = ReplicatedStorage:WaitForChild("RemoteEvent")

script.Parent.Button.MouseButton1Click:Connect(function()
	if debounce == false then
		if toggled == true and game.SoundService.GameSound.Volume == 0.5 then
			debounce = true
			game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(0.25), {BackgroundColor3 = Color3.fromRGB(255, 85, 0)}):Play()
			game:GetService("TweenService"):Create(script.Parent.Circle, TweenInfo.new(0.25), {Position = UDim2.new(0,2,0,2)}):Play()
			game.SoundService.GameSound.Volume = 0
			RE:FireServer(game.SoundService.GameSound.Volume)
			wait(0.25)
			debounce = false
			toggled = false
		elseif toggled == false and game.SoundService.GameSound.Volume == 0 then
			debounce = true
			game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(0.25), {BackgroundColor3 = Color3.fromRGB(64, 200, 114)}):Play()
			game:GetService("TweenService"):Create(script.Parent.Circle, TweenInfo.new(0.25), {Position = UDim2.new(1,-20,0,2)}):Play()
			game.SoundService.GameSound.Volume = 0.5
			RE:FireServer(game.SoundService.GameSound.Volume)
			wait(0.25)
			debounce = false
			toggled = true
		end
	end
end)

RE.OnClientEvent:Connect(function(volume)
	if volume == 0.5 then
		game.SoundService.GameSound.Volume = 0.5
		script.Parent.BackgroundColor3 = Color3.fromRGB(64, 200, 114)
		script.Parent.Circle.Position = UDim2.new(1,-20,0,2)
	elseif volume == 0 then
		game.SoundService.GameSound.Volume = 0
		script.Parent.BackgroundColor3 = Color3.fromRGB(255, 85, 0)
		script.Parent.Circle.Position = UDim2.new(0,2,0,2)
	end
end)

Very very weird, but doesn’t work at all

try this

local toggled = true
local debounce = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RE = ReplicatedStorage:WaitForChild("RemoteEvent")

script.Parent.Button.MouseButton1Click:Connect(function()
	if debounce then
		return
	end
	
	debounce = true
	
	if toggled == false then
		toggled = true
		game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(0.25), {BackgroundColor3 = Color3.fromRGB(255, 85, 0)}):Play()
		game:GetService("TweenService"):Create(script.Parent.Circle, TweenInfo.new(0.25), {Position = UDim2.new(0,2,0,2)}):Play()
		game:GetService("SoundService").GameSound.Volume = 0
		RE:FireServer(game.SoundService.GameSound.Volume)
	elseif toggled == true then
		toggled = false
		game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(0.25), {BackgroundColor3 = Color3.fromRGB(64, 200, 114)}):Play()
		game:GetService("TweenService"):Create(script.Parent.Circle, TweenInfo.new(0.25), {Position = UDim2.new(1,-20,0,2)}):Play()
		game:GetService("SoundService").GameSound.Volume = 0.5
		RE:FireServer(game.SoundService.GameSound.Volume)
	end
        task.wait(.25)
        debounce = false
end)

RE.OnClientEvent:Connect(function(volume)
	if volume == 0.5 then
		game:GetService("SoundService").GameSound.Volume = 0.5
		script.Parent.BackgroundColor3 = Color3.fromRGB(64, 200, 114)
		script.Parent.Circle.Position = UDim2.new(1,-20,0,2)
	elseif volume == 0 then
		game:GetService("SoundService").GameSound.Volume = 0
		script.Parent.BackgroundColor3 = Color3.fromRGB(255, 85, 0)
		script.Parent.Circle.Position = UDim2.new(0,2,0,2)
	end
end)

i suck i forgot the switch the debounce

1 Like

For this one it does switch on but not off, and for the other one it doesn’t switch on

let me try

Thanks that worked, @coo1ifyy also thanks for your help!

1 Like

i recommended using task library for the waits.because waits are going to get deprecated.use task.wait() instead of wait().

2 Likes

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