I am trying to send a table of results from a search in my datastore.
My Issue is that the result is duplicated in the Client
I have only printed the result in the ServerScript
In the first Search, it prints two results which are expected and In the second one, it prints one result and other as nil which is, again, expected.
This is the Server Script
game.ReplicatedStorage.Slide1.SearchEvent.OnServerEvent:Connect(function(plr,action, query, SideScroll)
local result = {}
for _, items in pairs(GameDataFolder:GetChildren())do
local Tags = string.split(items.Tags.Value, ".")
for _,tags in pairs(Tags) do
if query == tags then
table.insert(result,#result + 1, tonumber(items.Name))
end
end
end
if #result > 0 then
print(result[1])
print(result[2])
game.ReplicatedStorage.Slide1.SearchEvent:FireClient(plr, result,SideScroll )
else
game.ReplicatedStorage.Slide1.SearchEvent:FireClient(plr, false, SideScroll)
end
end)
This is the Local Script
for i,v in pairs(script.Parent:GetChildren())do
if v:IsA("Folder") then
game.ReplicatedStorage.Slide1.SearchEvent:FireServer(1, v.SideScroll.RequiredTags.Value, v.SideScroll)
print("sent")
game.ReplicatedStorage.Slide1.SearchEvent.OnClientEvent:Connect(function(result, SideScroll)
if result ~= false then
for _,item in pairs(result)do
print(item)
local createButton = Template:Clone()
createButton.Position = UDim2.new((#SideScroll:GetChildren() -1 )*0.05,0,1,0 )
createButton.PlaceId.Value = item
createButton.Parent = SideScroll
for i,value in pairs(SideScroll:GetChildren())do
if value:IsA("TextButton") then
local isSuccessful, info = pcall(marketplaceService.GetProductInfo, marketplaceService, value.PlaceId.Value)
if isSuccessful then
value.Text = info.Name
value.IconLabel.Image = "rbxthumb://type=Asset&id="..info.IconImageAssetId.."&w=150&h=150"
end
value.MouseButton1Click:Connect(function()
creatingPage.createPage("Game", value)
end)
else
end
end
end
else
print("No Result")
end
end)
end
end
Sorry for the terrible format
Any help would be Useful.