Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get numbers between two numbers and then set a limit for volume?

Alright, so it's like a range between two numbers, it's supposed to be if someone puts like 2 volume it wouldn't work and it would be reset back to 1. Let's say it is 0 to 1, and a user can change the volume from 0 to 1 (All the numbers between 0 and 1)

Here's an example of me trying to do this.

game.ReplicatedStorage.Volume.OnServerEvent:Connect(function(plr, thing)
	if thing == 0 > 1 then
		plr.Character.BoomboxBack.Sound.Volume = thing
	else
		plr.Character.BoomboxBack.Sound.Volume = 0.5
    end
end)

So "if thing == 0 > 1 then" is supposed to do what i was saying, but it won't work and it gives me errors. I'm kinda new to this and am still learning. So if the user changes the volume of the sound and if the volume is over 1 then it would reset back to 0.5.

I really can't find ANYTHING about "How to get all numbers between two numbers".

Idk how to explain better, as you can see am not English.

Thanks if you could correct me and give me some help! :)

1 comment

0

The word you're looking for is range.

1 answer

You were close. What you're looking for is:

if thing >= 0 and thing <= 1 then
	plr.Character.BoomboxBack.Sound.Volume = thing
else
	plr.Character.BoomboxBack.Sound.Volume = 0.5
end

..where '>=' stands for greater than or equal, and '<=' is less than or equal.

This discussion is preserved as it was. New answers, comments, and votes are closed.