Table is nil when obviously not, help?
Asked by
3 years ago Edited 3 years ago
The title says it all
it keeps erroring about line 105 when data[plr.name]["endings"] is nil for a new player
code : (VERY LONG)
002 | local dss = game:GetService( "DataStoreService" ) |
003 | local ed = dss:GetDataStore( "testds1" ) |
016 | local ms = game:GetService( "MarketplaceService" ) |
019 | game.Players.PlayerAdded:Connect( function (plr) |
021 | local pdat = ed:GetAsync(plr.UserId) |
026 | data [ plr.Name ] = pdat |
027 | if data [ plr.Name ] [ "endings" ] = = nil then |
028 | data [ plr.Name ] [ "endings" ] = { } |
030 | if data [ plr.Name ] [ "ADT" ] = = nil then |
031 | data [ plr.Name ] [ "ADT" ] = { } |
033 | data [ plr.Name ] = ed:GetAsync(plr.UserId) |
035 | game.ReplicatedStorage.CMode:FireClient(plr, "c" ) |
037 | if ms:UserOwnsGamePassAsync(plr.UserId, 17855260 ) then |
039 | game.Workspace.tipnote.PinNote.Interactive:Destroy() |
040 | game.Workspace.tipnote.CD:Destroy() |
041 | game.Workspace.tipnote.PinNote.SurfaceGui.TextLabel.Text = "ty for donating" |
044 | local plrdata = data [ plr.Name ] |
049 | if not plr:IsInGroup( 4199740 ) then |
051 | if game.Workspace:FindFirstChild( "YTNOTE" ) ~ = nil then |
052 | game.Workspace.YTNOTE:Destroy() |
055 | local ep = game.ServerStorage.Endings |
058 | if plrdata [ "ADT" ] = = "bfst" then |
059 | plr.Character.HumanoidRootPart.Postition = game.Workspace.TPPs.VTL |
063 | local plrdats = data [ plr.Name ] |
064 | if plrdats [ "NF" ] ~ = nil then |
065 | local nfs = plrdats [ "NF" ] |
067 | if game.Workspace:FindFirstChild( "Not1" ) ~ = nil and game.Workspace:FindFirstChild( "Not3" ) ~ = nil then |
068 | game.Workspace.Not 1 :Destroy() |
069 | game.Workspace.Not 3 :Destroy() |
072 | if game.Workspace:FindFirstChild( "Not1" ) ~ = nil and game.Workspace:FindFirstChild( "Not2" ) ~ = nil then |
073 | game.Workspace.Not 2 :Destroy() |
074 | game.Workspace.Not 1 :Destroy() |
078 | if game.Workspace:FindFirstChild( "Not1" ) ~ = nil and game.Workspace:FindFirstChild( "Not2" ) ~ = nil and game.Workspace:FindFirstChild( "Not3" ) ~ = nil then |
079 | game.Workspace.Not 1 :Destroy() |
080 | game.Workspace.Not 2 :Destroy() |
081 | game.Workspace.Not 3 :Destroy() |
084 | elseif plrdats [ "NF" ] = = nil then |
085 | if game.Workspace:FindFirstChild( "Not1" ) ~ = nil and game.Workspace:FindFirstChild( "Not2" ) ~ = nil and game.Workspace:FindFirstChild( "Not3" ) ~ = nil then |
086 | game.Workspace.Not 1 :Destroy() |
087 | game.Workspace.Not 2 :Destroy() |
088 | game.Workspace.Not 3 :Destroy() |
093 | local endings = data [ plr.Name ] [ "endings" ] |
094 | gendings [ plr.Name ] = endings |
096 | print (gendings [ plr.Name ] ) |
097 | print (data [ plr.Name ] ) |
098 | print (data [ plr.Name ] [ "endings" ] ) |
103 | for _,v in pairs (gendings [ plr.Name ] ) do |
104 | if ep:FindFirstChild(v) ~ = nil then |
105 | ep:FindFirstChild(v):Clone().Parent = game.Workspace.Endings |
108 | if #gendings [ plr.Name ] > = #game.ServerStorage.Endings:GetChildren() - 1 then |
109 | ep:FindFirstChild( "All Endings" ).Parent = game.Workspace.Endings |
113 | if math.random( 1 , 1000 ) ~ = 532 then |
114 | game.Workspace.Vent:Destroy() |
119 | if table.find(trusted, plr.Name) ~ = nil then |
120 | game.ServerStorage.ProPanel.Parent = plr.PlayerGui |
124 | local moneydata = Instance.new( "Folder" , game.ServerStorage.Plrdat) |
125 | moneydata.Name = plr.Name |
126 | local moneyvalue = Instance.new( "IntValue" , moneydata) |
127 | moneyvalue.Name = "Money" |
129 | local moneyframe = plr.PlayerGui.MoneGui.Frame |
130 | moneyframe.Amount.Text = moneyvalue.Value |
131 | moneyvalue.Changed:Connect( function () |
132 | moneyframe.Amount.Text = moneyvalue.Value |
134 | local isoutside = Instance.new( "BoolValue" , plr) |
135 | isoutside.Name = "IsOut" |
139 | game:BindToClose( function () |
140 | for _, v in pairs (game.Players:GetChildren()) do |
142 | data [ plr.Name ] [ "endings" ] = gendings [ plr.Name ] |
143 | print (data [ plr.Name ] ) |
144 | if data [ plr.Name ] ~ = ed:GetAsync(plr.UserId) then |
145 | ed:SetAsync(plr.UserId, data [ plr.Name ] ) |
150 | game.Players.PlayerRemoving:Connect( function (plr) |
151 | data [ plr.Name ] [ "endings" ] = gendings [ plr.Name ] |
152 | print (data [ plr.Name ] ) |
153 | if data [ plr.Name ] ~ = ed:GetAsync(plr.UserId) then |
154 | ed:SetAsync(plr.UserId, data [ plr.Name ] ) |
158 | script.Parent.Events.addEND.Event:Connect( function (data, plr) |
159 | for _,v in pairs (gendings [ plr.Name ] ) do |
164 | table.insert(gendings [ plr.Name ] , data) |
167 | script.Parent.Events.getEND.OnInvoke = function (plr) |
168 | return gendings [ plr.Name ] |
171 | script.Parent.Events.MD.Event:Connect( function (plr, i, v) |
173 | print (data [ plr.Name ] ) |
174 | if data [ plr.Name ] [ "rdata" ] [ i ] = = v then |
177 | data [ plr.Name ] [ "rdata" ] [ i ] = v |
180 | script.Parent.Events.GD.OnInvoke = function (plr) |
181 | return data [ plr.Name ] [ "rdata" ] |