Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
ewum 0
6 years ago

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! :)

0
The word you're looking for is range. Meltdown81 309 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question