local NumberRangeTables = {
[NumberRange.new(0, 20)] = 8, -- Between 0 to 20 = 8
[NumberRange.new(21, 75)] = 5, -- Between 21 to 75 = 5
[NumberRange.new(76, 150)] = 3,
[NumberRange.new(150, 200)] = 2,
[NumberRange.new(201, 300)] = 1.5,
[NumberRange.new(301, math.huge)] = 0.5
}
function CreateTweenBar()
RegenBarFrame(BarFrame.Size.X.Scale)
TweenTrack:Cancel()
TweenTrack = _TweenService:Create(BarFrame,
-- ERROR
TweenInfo.new(NumberRangeTables[StairCount]), {Size = Udim2new(0, 0, 1, 0)})
TweenTrack:Play()
end
What is the error you are getting?
You are setting your indexes for the table to NumberRange instances, in which you can not access them with 1, 2, 3, etc.
I am not entirely sure what you are trying to accomplish here, but a better alternative is probably to just use an if statement.
Ex:
local seconds
if StairCount >= 301 then
seconds = 0.5
elseif StairCount >= 201 then
seconds = 1.5
elseif StairCount >= 150 then
seconds = 2
elseif StairCount >= 76 then
seconds = 3
elseif StairCount >= 21 then
seconds = 5
else
seconds = 8
end
The only other way to do it in the way you are using the table, is to create a bunch of tables with table.create
and then combine them together with table.move
, but you are also limited, since using math.huge, will probably not turn out too well.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.