Are there any errors in your output? If there are, please screenshot them (unless the error’s the one in the title of the thread).
I’d also suggest doing FindCartelInTable["Members"] += 1 to shorten your code (also is less to type, and would save you some hassle if you renamed ‘Members’ to something else).
The full script is 200 lines and can get confusing, here is the function
local function leave_join_func(player, id, status)
local Bools = player:FindFirstChild("Bools")
local focus_cartel = FamilyFolder:FindFirstChild("cartelid".. id)
--local FindCartelInTable = Cartel_Info[id]
local CartelOwnerInst = game.Players:GetPlayerByUserId(focus_cartel.OwnerID.Value)
local OwnerGui = CartelOwnerInst.PlayerGui
local NotifAskGui = OwnerGui:FindFirstChild("AskToJoin")
local Accept = NotifAskGui.Frame.Accept
local Decline = NotifAskGui.Frame.Decline
local HeadShot = NotifAskGui.Frame.Headshot
local Content = NotifAskGui.Frame.Content
av_headshot(player, HeadShot)
if status == "J" then
print(status)
NotifAskGui.Enabled = true
Content.Text = player.Name.. " would like to join your cartel"
Accept.MouseButton1Click:Connect(function()
Content.Text = player.Name.. " has joined your cartel!"
wait(1)
NotifAskGui.Enabled = false
Cartel_Info[id]["Members"] += 1
print("worked?")
Bools.IsInCartel.Value = true
Bools.CartelId.Value = id
SetInfo()
UpdateTable()
end)
Decline.MouseButton1Click:Connect(function()
NotifAskGui.Enabled = false
end)
elseif status == "L" then
print(status)
Bools.IsInCartel.Value = false
Bools.CartelId.Value = nil
SetInfo()
UpdateTable()
end
end
This simply means the table doesn’t exist. I’d suggest putting something in place to prevent the error from happening, just so nothing breaks.
Example:
local FindCartelInTable = Cartel_Info[id]
if FindCartelInTable then
FindCartelInTable["Members"] += 1
else
warn("Cartel", id, "doesn't exist!")
end
That is not their problem, I’m assuming their problem is they think they are making new cartel objects when they really aren’t that’s why I asked for the rest of the script.
Can you send where Cartel_Info is created, I think you are creating a blank table when you do Cartel_Info[id], what you have to do is make it a class (OOP) and assign a “new” function which creates a new cartel when called
The IDs mismatch then, if it is a valid ID yet doesn’t register on that other code snippet. Try printing the ID when you are about to increment the Members value?
local sus_ranks = {
baka = { "tanjiro", "gojo" }
}
local clone = sus_ranks.baka -- gets content and make a new context
clone[1] = "literal sussy baka" -- changing the "tanjiro" value in the clone to the "new value"
print(sus_ranks.baka) --> { "tanjiro", "gojo" }
Oh I see so the the Cartel_Info table is supposed to already exist.
In that case when is the previous function running? By the name it seems it’s running when the player joins. The Cartel might not have been created when the leave_join_func function runs.
No, the create function runs when the player clicks “Create Cartel”, then clicks on “Join cartel” and the cartel owner is asked to accept the new player. When the owner accepts, the members go +1 and the script update the datastore
Okay so I recommend printing out Cartel_Info in the leave_join_func and see what that prints, if that prints nil you know either “Cartel_Info” doesn’t exist or you are not accessing it (it might not be accessible to this function, is this all in one script? if not how does leave_join_func get access to the Cartel_Info table and is it really accessing it properly or is it returning nil?)
If Cartel_Info does exist you can print “Cartel_Info[id]” and see if that exists (maybe it’s not creating Cartel_Info[id] like you think it is or it’s using a different id)
P.s. sorry it’s hard to diagnose the problem when I don’t know the full script and how everything works
P.p.s. if you know the name of a member to a dictionary (not a variable) you can access it like Cartel_Info[id].Members += 1
instead of Cartel_Info[id]["Members"] += 1
I believe that is the preferred syntax