How can I get my GUI text to match with a table?

What im trying to achieve is when i press the next or backwards button the map text changes based on the table and when it gets to the first or last value which is “House” it stops and you cant go further

My Code:

local Maps = {
   "Bank",
   "Hotel",
   "House"
}

local Configurations = {

   Map = "Bank"
}

MapGui.Next.Activated:Connect(function()
   Configurations.Map = Maps[]

   MapLabel.Text = Configurations.Map

end)

MapGui.Back.Activated:Connect(function()

--Idk anymore

end)

You can do something like this:

local index = 1 -- a variable corresponding to the place in the table you're in

button.Activated:Connect(function()
index = math.clamp(index + 1, 1, 3)-- or "index - 1" if you want to go backward
Configurations.Map = Maps[index]
-- insert code here
end)

If you want to read on what math.clamp does, this may work.

Hope this helps!

2 Likes

Yeah i know what it does i just had no idea how to approach it, thanks alot

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.