steezyflo
(steezyflo)
February 22, 2022, 1:58am
#1
This is just a quick problem, but for some reason it gives me an error when putting this in.
local temp = 98.6
local counter = 93
temp.MaxValue = 98.6
counter.MaxValue = 93
The error is:
Workspace.Zox_Dev.Tempreature:4: attempt to index number with ‘MaxValue’
TenBlocke
(Decablocks)
February 22, 2022, 2:09am
#2
Variables temp and counter are numbers, you tried to get .MaxValue of a number which does not exist. What are you trying to do exactly?
It seems they want to establish a MaxValue for their variables. But its something that is not built into Roblox itself. They need to program it themselves.
Koiyukki
(Koyukki)
February 22, 2022, 2:13am
#4
Maybe this is what you could be looking for?
local number = {Max = 7, Min = 1}
print(number.Max)
prints the “max” number, which is 7 in this case.
TenBlocke
(Decablocks)
February 22, 2022, 2:16am
#5
or
local temp = 98.6
local counter = 93
print(math.max(temp,counter)) --98.6
Koiyukki
(Koyukki)
February 22, 2022, 2:17am
#6
Well when you do this the variable doesn’t have a “max value”, which I think is what they want.
You can do
local max = 10
local min = 1
local intvalue = intvaluepath
intvalue.Changed:Connect(function()
intvalue.Value = math.clamp(intvalue.Value, min, max)
end)
U can do it with number values too
steezyflo
(steezyflo)
February 22, 2022, 2:21am
#8
okay, So I am making it so that they go down and up, they can go down as much as they want but I don’t want them to ever go higher than the maxvalue
You can try my method. It works fine. You can do it with decimals and ints
TenBlocke
(Decablocks)
February 22, 2022, 2:23am
#10
you can use the example @luisgamercooI231fan sent above since you can make its min value as low as you want and limit the max
Koiyukki
(Koyukki)
February 22, 2022, 2:45am
#11
I’m not sure if they want a variable with variables min and max, or when a variable is changing to be set.
steezyflo
(steezyflo)
February 22, 2022, 4:06am
#12
I am trying to make it so that the number can go down as much as it wants, but the temp cannot go above 98.6, and the counter cannot go above 93
Koiyukki
(Koyukki)
February 22, 2022, 8:55am
#13
Use math.clamp then.
local number = math.clamp(number, min, max)
1 Like