Hello guys, so lately I have been trying to access a table within a module script that has nothing in it, once players join, data gets added, but when I request said data from a script in the server via require
it shows me that nothing is in it. So Idk whether the table.insert
is not actually working in the server script or if the server script is not retrieving the table correctly, some help?
ok so its a dictionary right? And are you creating methods to actually insert the data? It would be nice if you showed us what you did so far
I have used this on the server script
table.insert(radioModule.Callsigns, {
[infoTable.callsign] = {Owner = plr.Name}
})
But it does not seem to be added into the dictionary as you call it
is Callsigns in the module table
Here it is.
local radio = {}
radio.Clearance = {
--["team name"] = {Webhook = ""},
["Police"] = {Webhook = ""},
["Criminals"] = {Webhook = ""}
}
radio.Callsigns = {
--["callsign number"] = { Owner = plrName }
}
return radio
I don’t see any problem can you show the server script too?
– SERVER
CallsignEvent.OnServerEvent:Connect(function(plr, infoTable, gui)
if checkClearance(plr) then
gui:Destroy()
table.insert(radioModule.Callsigns, {
[infoTable.callsign] = {Owner = plr.Name}
})
script.Radio:Clone().Parent = plr.PlayerGui
else
plr:LoadCharacter()
warn("Unauthorized access from "..plr.Name.." into the radio system.")
end
end)
MODULE
local radio = {}
radio.Clearance = {
--["team name"] = {Webhook = ""},
["Police"] = {Webhook = ""},
["Criminals"] = {Webhook = ""}
}
radio.Callsigns = {
--["callsign number"] = { Owner = plrName }
}
return radio
but the table insert just does not work at all and i dont know why, I checked other forums and they say you can use table insert for module tables too
Everything else works except for table.insert?
indeed, everything else works just as fine, idk whats wrong on table insert smh
I really don’t see a problem with the scripts you gave unless its not from those scripts.
table.insert(radioModule.Callsigns, {
[infoTable.callsign] = {Owner = plr.Name}
})
print(radioModule.Callsigns)
Fixed it, table.insert
seems to be useless, so the way I made it is to define stats the following way:
OLD
table.insert(radioModule.Callsigns, {
[infoTable.callsign] = {Owner = plr.Name}
})
NEW
radioModule.Callsigns[infoTable.callsign] = {Owner = plr.Name}
Nice, that is a good alternative. The only reason I can think of is because since it becomes a dictionary it has to have an index key.
radioModule.Callsigns[infoTable.callsign] = {Owner = plr.Name}
sets the key to infoTable.callsign but
table.insert(radioModule.Callsigns, {
[infoTable.callsign] = {Owner = plr.Name}
})
has no key
The key in this case would of been infoTable.Callsign that is unique but seems it didnt work
If you mean with table.insert then they key is actually 1 because when you insert a dictionary into a table, it must be tied to a key
OH you mean the index, well yeah I also tried doing such thing but it didnt work…