Hello again!
I’ve hit another brick wall, with another thing that I know almost nothing about. I’ve been trying to make a “Database” system where an officer can enter a suspect’s name, and it will return with the suspect’s criminal record like shown here:
(This one is from another game)
And I’ve gotten pretty far for my knowledge, but I’m having a major issue: It only returns 8 values.
I’ve tried asking scriptinghelpers (another developer website that helps out most of the time), but I haven’t gotten much help. Any help would be greatly appretiated!
Code:
script.Parent.MouseButton1Down:Connect(function()
if string.len(script.Parent.Parent:WaitForChild("Search_Box").Text) >= 3 then -- checks if it's at least three characters long, which is roblox's minimum amount
local recordObject = game:GetService("ReplicatedStorage"):WaitForChild("getRecord"):InvokeServer(script.Parent.Parent:WaitForChild("Search_Box").Text)
if recordObject == true then
script.Parent.Text = "Success"
wait(3)
script.Parent.Text = "Search Database"
else
if recordObject ~= nil then
script.Parent.Text = recordObject
else
script.Parent.Text = "Undefined Error"
end
wait(3)
script.Parent.Text = "Search Database"
end
end
end)
ServerScript:
local function getRecord(player,lookedUp)
local success,errorMessage = pcall(function()
local data = {}
local recordDataStore = game:GetService("DataStoreService"):GetOrderedDataStore(lookedUp.."_RecordData")
local dataAsync = recordDataStore:GetSortedAsync(true,100)
local dataPages = dataAsync:GetCurrentPage()
for i,v in pairs (player.PlayerGui.Database.Frame.Main["Arrests/Citations"].Arrests:GetChildren()) do
v:Destroy()
end
player.PlayerGui.Database.Frame.Main["Arrests/Citations"].arrestButtons.CurrentPage.Value = 1
for i = 1, #dataPages do
local record = dataPages[i]
local newPage = game.ServerStorage.GUI.ArrestWrapper:Clone()
newPage.Parent = player.PlayerGui.Database.Frame.Main["Arrests/Citations"].Arrests
newPage.Arrests["01"].Text = record.key
newPage.Name = "arrest_"..i
if i ~= 1 then
newPage.Visible = false
end
end
end)
if not success then
return errorMessage
else
return true
end
end
game:GetService("ReplicatedStorage"):WaitForChild("getRecord").OnServerInvoke = getRecord
I do intend to change some things to make it foolproof, but this is only a testing version.
Roblox File: Database.rbxl (30.8 KB)
(Blue button is to open the GUI, Red Button is to add an arrest under a random name)