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)
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.
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 ????)