Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Does anyone know why this error happens when I try to change the table?

Asked by 6 years ago
Edited 6 years ago

This is the script:

local xs= game:GetService('DataStoreService'):GetDataStore('tester8')
local at = {}
local Players = game.Players
local plr = game.Players.LocalPlayer
local ss = game:GetService('ServerStorage')
local rs = game:GetService('ReplicatedStorage')
local house = rs.house
local price = house.price
local filteringname = rs.filtering.filtername





Players.PlayerAdded:Connect(function(plr)
    at[plr] = {}
    at[plr].zs = {}
    local zs= xs:GetAsync("BOBBY"..plr.UserId)


    if zs then

        print("loading")
            at[plr].zs = zs

                local number = at[plr].zs.Okans
             price:FireClient(plr,number)

    else

        print("first join loading base data")
        at[plr].zs.Okans = 1000
        at[plr].zs.Grade = {50,"B"}
        at[plr].zs.furniture = {}
        at[plr].zs.Grid = {}
        at[plr].zs.Orient = {}
        at[plr].zs.skin1 = {}
        at[plr].zs.skin2 = {}
        at[plr].zs.skin3 = {}
        at[plr].zs.ammount = {}
        at[plr].zs.name = {plr.Name}





        xs:SetAsync("BOBBY"..plr.UserId,at[plr].zs)


        local number = at[plr].zs.Okans
             price:FireClient(plr,number)


    end
end)







local function setname (filteredText)
    at[plr].zs.name = {filteredText}
    function save()
        xs:SetAsync("BOBBY"..plr.UserId,at[plr].zs)
    end
  local s = pcall (save)
if s then
    print('good')
else
    print('bad')
end
end




filteringname.OnServerEvent:Connect(function(player,t3xt)
    print(player.Name)
    local mod = nil
    if t3xt ~= "" then
        local filteredText = ""
        local success, message = pcall(function()
            filteredText = game.Chat:FilterStringForBroadcast(t3xt, player)
        end)
        print(filteredText)
            if success then
            local hashtag = {"#"}
    for i=1,#hashtag do
        if filteredText:find(hashtag[i]) then

             mod = 'yes'
filteringname:FireClient(mod)
else

     mod = 'no'
setname()

    print(at[plr].zs.name[1])

    filteringname:FireClient(mod)
    print('end')
end
end
            end
        end
        end)




(credit to Sebby for the i loop part, thanks sebby! :D)

I have no Idea why this error happens and I've been trying to figure this out for 2 hours.

this is the error by the way : 17:54:26.202 - ServerScriptService.data:87: attempt to index field '?' (a nil value)

0
btw in the full script 87 would be 02 Unbunn_makes 48 — 6y
0
It's hard to solve when I don't exactly know what "at" and "zs" is. What is it? Also is [plr] the player name? User#20279 0 — 6y
0
there I fixed it now you can see the full thing Unbunn_makes 48 — 6y
0
So I don't know a lot about tables, but at line 16, are you trying to insert the player into the "at" table? I usually see numbers in those brackets which are supposed to get something in the table. User#20279 0 — 6y
View all comments (2 more)
0
Nothing seems wrong. However, if you check if the message is blank, use "not t3xt:match('^%s+$') hiimgoodpack 2009 — 6y
0
Nothing seems wrong. However, if you check if the message is blank, use "not t3xt:match('^%s+$')" to make sure there is no whitespace. Also, please indent correctly. hiimgoodpack 2009 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I haven't read the entire script, but I noticed that you aren't using the table.insert function, which might help to stabilize your script. It works like this

local myTable = {}

table.insert(myTable, "This is what I am inserting!"")

table.insert(myTable, 8)
print(table.concat, ", ")

Output: This is what I am inserting!, 8

table.concat is equal to all the contents of the table defined in the argument. the second argument is what is inserted in between the individual contents of the table.

table.remove(myTable, 2) would remove the second thing in the table.

0
I won't work, I even took it out of a table it still doesn't work :( Unbunn_makes 48 — 6y
0
Dang... Sorry to hear. Myh inventory thing also stopped working and I have no idea why. I made a post about it here. I'm going to re-write the thing from scratch, probably tomorrow. Kato12345 17 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I can't test this code myself right now, but I think the problem is that "filteredText" is nil because the FilterString failed for some reason, use if-then statements to prevent this, e.g.

if filteredText == nil then --or you can just use "if not filteredText"
    print("My filter failed")
else
    print(filteredText)
end

If this doesn't work let mew know.

EDIT: Try using this code instead of your current pcall's:

local success, message = pcall(function()
    return game.Chat:FilterStringForBroadcast(t3xt, player)
end)
if success then
    print(message) -- Prints the filtered text
else
    warn(message) -- Prints the error
end

(P.S. thanks for crediting me, always happy to help ????)

0
that "????" is a smile emoji SebbyTheGODKid 198 — 6y

Answer this question