Title might be confusing. I’m not talking about ScrollingFrames, but using a Previous and Next button, to basically scroll through items.
The basic problem I am facing is that the current way I am going about this is going to end up convoluted when I add in more items over time.
previousPage.Activated:Connect(function()
if var.selected ~= 'Knight' then
var.selected = 'Knight'
class.Text = var.selected
previousPage.ImageColor3 = Color3.fromRGB(25, 25, 25)
nextPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
end
end)
nextPage.Activated:Connect(function()
if var.selected ~= 'Archer' then
var.selected = 'Archer'
class.Text = var.selected
nextPage.ImageColor3 = Color3.fromRGB(25, 25, 25)
previousPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
end
end)
Since I currently only have 2 classes, it isn’t that convaluted, but when I move onto say 10, it’d start to become really clustered. For example, let’s say next class is a Scout:
previousPage.Activated:Connect(function()
if var.selected == 'Archer' then
var.selected = 'Knight'
class.Text = var.selected
previousPage.ImageColor3 = Color3.fromRGB(25, 25, 25)
nextPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
elseif var.selected == 'Scout' then
var.selected = 'Archer'
class.Text = var.selected
previousPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
nextPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
end
end)
nextPage.Activated:Connect(function()
if var.selected == 'Knight' then
var.selected = 'Archer'
class.Text = var.selected
nextPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
previousPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
elseif var.selected == 'Archer' then
var.selected = 'Scout'
class.Text = var.selected
nextPage.ImageColor3 = Color3.fromRGB(85, 170, 255)
previousPage.ImageColor3 = Color3.fromRGB(25, 25, 25)
end
end)
And basically every class added would add an extra 10 or so lines to the script. I’m guessing somehow adding a for loop that loops through the classes from a table might be able to minimise the code, but not entirely sure how to go about that and how to have it recognise what colors the next and previous buttons would have to be (Knight being first in the list, so the Next button is Blue, Previous is grey, and Scout being the last in the list, so Next being Grey and Previous being Blue)