Hello, I tried asking on an older post but I had not recieved a response since then so I’ll re-iterate my issue here since its a different issue anyway
So, I have this script which cycles through different “Modes” of a table. But, the way it’s written, I can’t think of a way to get the index and its properties out so I can reference them.
local Modes = {
{["Name"] = "Dreamcaster"},
{["Name"] = "Fireclaw"},
{["Name"] = "Guardian"},
{["Name"] = "The Manual"},
{["Name"] = "Console"},
}
CurrentMode = 0
Form = Instance.new("IntValue")
Form.Parent = char
Sword.CanCollide = false
Sword.Parent = char
SW = Instance.new("WeldConstraint")
SW.Parent = char
SW.Part0 = char.Torso:FindFirstChild("BackProxy")
SW.Part1 = Sword
Sword.Position = char.Torso:FindFirstChild("BackProxy").Position
Sword.BlueGlow.Position = Sword.Position + Vector3.new(1.11,1,0)
function IterateModes(Table, StartingIndex, Increase)
local Max = #Table
print(Max)
local NewMode
if Increase then
if (StartingIndex + 1) > Max then
NewMode = 1
else
NewMode = StartingIndex + 1
end
CurrentMode = NewMode
else
if (StartingIndex - 1) < 1 then
NewMode = Max
else
NewMode = StartingIndex - 1
end
CurrentMode = NewMode
end
end
UIS.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.E then
local Final = IterateModes(Modes, CurrentMode, true)
end
if Key.KeyCode == Enum.KeyCode.Q then
local Final = IterateModes(Modes, CurrentMode, false)
end
end)
How would I get a specific index’s property? The cycle outputs a number from 1-5 but How would i compare this to my table’s index and get the properties of the index number that matches the current one gained from the cycle?