What do you want to achieve? Keep it simple and clear!
I am trying to concatenate a string and a number, and have it refer to an existing table when called on.
What is the issue? Include screenshots / videos if possible!
local Quest1 = {
["Title"] = "Fist",
["Task"] = {"Gain 20 Strength", 20, "Strength"},
["Reward"] = 100
}
for Value = 1,36 do
if QuestNumber.Value == Quest then
QuestAssign = ("Quest"..Value)
print(QuestAssign)
end
end
Later on in the script, I have the following line of code which is giving me an error message saying: ServerScriptService.Quest:565: invalid argument #1 to ‘pairs’ (table expected, got string)
for _, Value in pairs(QuestAssign) do
if _ ~= "Task" then
Quests:WaitForChild("Quest".._).Value = Value
else
Quests:WaitForChild("QuestTask").Value = Value[1]
Quests:WaitForChild("QuestObjective").Value = Value[2]
Quests:WaitForChild("QuestStatistic").Value = Value[3]
end
end
I see what you are trying to do! What you can do is:
Make a dictionary of all the quests like so:
local Quests = {
}
Then add an index for each quest like so:
local Quests = {
[1] = {
["Title"] = "Fist",
["Task"] = {"Gain 20 Strength", 20, "Strength"},
["Reward"] = 100}
[2] = {blablabala} -- you continue here with other quests you want to add
}
Then you index the Quests table with the quest value, so:
local Quests = {
[1] = {
["Title"] = "Fist",
["Task"] = {"Gain 20 Strength", 20, "Strength"},
["Reward"] = 100}
[2] = {blablabala} -- you continue here with other quests you want to add
}
for Value = 1,36 do
if QuestNumber.Value == Quest then
QuestAssign = Quests[Value]
print(QuestAssign)
end
end