would that change how it goes into the dictionary though
No, thatād be table.insert()
Youāre attempting to find if a Raceās Name is not valid to the RaceData
so you can change its values to them
Tables are definitely fun
Yeah I used table.find() instead and it still printed ā1ā and āNumberOfRacersā for index,value of the RoadRace dictionary
Well, somewhere in there youāre still referencing the square brackets if itās indexing back as numbers
Could you at least show the script that handles everything?
Yeah hold on.
local RaceModule = require(game.ServerScriptService.ServerScripts.RaceModule)
local Races = game.workspace.Races:GetChildren()
RaceModule.InitiateRaceData(Races)
This is the server script handler.
function RaceModule.InitiateRaceData(races)
if RaceSettings.TimeTrialMode == false then
for _, race in pairs(races) do
print(table.find(RaceData,race.Name))
if table.find(RaceData, race.Name) == nil then
RaceData[race.Name] = {
PlayersEnrolledInRace = {},
RaceMax = RaceSettings.NonTimeTrialModeMaxRacerCount,
NumberOfRacers = 0,
PlayersReadyForRace = 0,
StartTime = 0,
RaceStarted = false,
}
end
end
elseif RaceSettings.TimeTrialMode == true then
for _, race in pairs(races) do
print(table.find(RaceData, race.Name))
if table.find(RaceData, race.Name) == nil then
RaceData[race.Name] = {
PlayersEnrolledInRace = {},
RaceMax = 1,
NumberOfRacers = 0,
PlayersReadyForRace = 0,
StartTime = 0,
RaceStarted = false
}
end
end
end
end
This is RaceModule ^^
Note: Racesettings is another module with just settings, TimeTrialMode is on.
I also have a place in the module where this line is
RaceData[race.Name].PlayersEnrolledInRace[tostring(_)].HasStartedRace = true
ā_ā is the player name, it is referencing the playername in PlayersEnrolledInRace.
I think I found the easiest way to describe what I need.
local dictionary = {
["Apple"] = {
color = "red"
numbers = 5
}
["Orange"] = {
color = "red"
numbers = 5
}
}
This is the dictionary, if i did print(Dictionary.Orange)
, it would print its color
and numbers
. what if i wanted it to print Orange
In other words, is there a name property for the key.
There isnāt a Name
property for keys/indexes, Iām just lost on how to handle the situation
Youāll have to loop through the table, referencing its custom index values
Also, I know this is offtopic, but if you do Dictionary[āhiā] to make a new key in the dictionary, does it put it ANYWHERE in the dictionary, or in order( so at the end of the dictionary )
Not exactly sure, but my assumption is that it puts it anywhere in the Dictionary since itās not based on order
Ah alright thank you! And thanks for the help with the loop i forgot I could loop through it