I tried that, but it still isn’t working. No error at all.
Anyone have any more insight on this issue? I still can’t figure it out.
Have you tried using built-in debugging like breakpoints and watches to see what the code is doing in runtime?
For example, setting a breakpoint on the line
information.Arrests.Text = "Arrests:"..events.GetArrestData:InvokeServer(lookup,"GetArrestRecordAmount")
and just cycling through the code?
Background
As I was testing today, I placed:
- a
LocalScript
inStarterGui
which fired a RemoteFunction and printed its return value - the
RemoteFunction
inReplicatedStorage
- a
Script
(it was named DatabaseFE - I posted the source earlier, but I will post it again) inServerScriptStorage
which, on remote function invocation, returned the value “hi”. Important note: This script ALSO handled several OTHERRemoteFunctions
.
I tested this several times, each time with no success. The return value was never printed in the Output.
Discovery
On a whim, after remembering how I’d seen another similar system configured, I created a separate script for the aforementioned RemoteFunction.
This was the code in that script:
function gtd(plr,lookup,event)
return "hi"
end
game:GetService("ReplicatedStorage").GetTestData.OnServerInvoke = gtd
Voila! It worked…
I’m now left wondering why the original script did not work.
Script Source(s)
Source of DatabaseFE:
local events = game:GetService("ReplicatedStorage")
local databaseModule = require(game:GetService("ServerStorage").DatabaseModule)
function gtd(plr,lookup,event)
return "hi"
end
events.GetTestData.OnServerInvoke = gtd
function events.GetArrestData.OnServerInvoke(plr,lookup,event)
if event == "GetArrestRecords" then
return databaseModule.GetArrestRecords(lookup)
elseif event == "GetArrestRecordAmount" then
return #databaseModule.GetArrestRecords(lookup)
end
return nil
end
function events.GetCitationData.OnServerInvoke(plr,lookup,event)
if event == "GetCitationRecords" then
return databaseModule.GetCitationRecords(lookup)
elseif event == "GetCitationRecordAmount" then
return #databaseModule.GetCitationRecords(lookup)
end
return nil
end
Source of LocalScript:
print(1)
local lookup = game.Players.LocalPlayer
print(2)
local arrests = game:GetService("ReplicatedStorage"):WaitForChild("GetTestData"):InvokeServer(lookup,"GetArrestRecords")
print(arrests)
print(3)
I’d appreciate any help you can give.
Does your arrests variable still print nil?
There’s no print statement at all.
The original script’s output says:
1
2
Can you try splitting the local arrests line into separate sections so you can find out which part failed.
I ask as you did not get the 3 printed out so a previous line failed to complete.
add a print at the end of the server script and after the line with require() to see if the code is being run and that the require() finished yielding
Alrighty, I’ll make sure to do so tomorrow.
Do you think the issue could be with require()? If so, it’s not showing in the output.
yea, you might have something like an infinite loop inside the module making the require() never finish
Aha! You’re a genius!
The require call doesn’t work (the print after it does not print).
Here’s the code behind it - maybe you can tell me why it’s erroring?
local database = {}
local arrestsDS = game:GetService("DataStoreService"):GetDataStore("Database","Arrests")
local citationsDS = game:GetService("DataStoreService"):GetDataStore("Database","Citations")
local warrantsDS = game:GetService("DataStoreService"):GetDataStore("Database","Warrants")
local trelloAPI = require(game.ServerScriptService:WaitForChild("TrelloAPI"))
local arrestCitationsBoard = trelloAPI:GetBoardID("Arrest & Citation Records")
local warrantsBoard = trelloAPI:GetBoardID("Layden County Courts")
local arrestList = trelloAPI:GetListID("Arrests",arrestCitationsBoard)
local citationList = trelloAPI:GetListID("Citations",arrestCitationsBoard)
local warrantList = trelloAPI:GetListID("Active Warrants",warrantsBoard)
local httpService = game.HttpService
local keyprefix = "lcrecordid_"
--[TIME]--
-- convert time to human format
function getTime(epochTime)
local currentTime = os.date("!*t",epochTime)
local hour = currentTime.hour
local minute = currentTime.min
local second = currentTime.sec
local day = currentTime.day
local month = currentTime.month
local year = currentTime.year
if hour < 10 then
hour = 0 .. hour
end
if minute < 10 then
minute = 0 .. minute
end
if second < 10 then
second = 0 .. second
end
if day < 10 then
day = 0 .. day
end
if month < 10 then
month = 0 .. month
end
if year < 10 then
year = 0 .. year
end
return ("%s:%s:%s UTC on %s/%s/%s"):format(hour, minute, second, month, day, year)
end
--[ARRESTS]--
-- add an arrest to the given player's record; if there is no record, make one
function database.AddArrest(plr,officer,reason)
print(plr.Name)
trelloAPI:AddCard(plr.Name,"Arrested by: \n > ".. officer.Name .. "\n \n by: \n > ".. getTime(os.time()) .. "\n \n for: \n > ".. reason,arrestList)
local key = keyprefix..plr.userId
local record = arrestsDS:GetAsync(key)
if record then
table.insert(record,{plr.Name,officer.Name,reason})
arrestsDS:SetAsync(key,record)
else
local firstsave = {{plr.Name,officer.Name,reason}}
arrestsDS:SetAsync(key,firstsave)
end
end
-- retrieve the arrest records for the given player
function database.GetArrestRecords(plr)
local key = keyprefix..plr.userId
local record = arrestsDS:GetAsync(key)
if record then
return record
else
return {}
end
end
--[CITATIONS]--
--save a citation to the player's record; if there is no record, make one
function database.AddCitation(plr,officer,reason,amount)
local key = keyprefix..plr.userId
local record = citationsDS:GetAsync(key)
trelloAPI:AddCard(plr.Name,"Cited by: \n > ".. officer.Name .. "\n \n by: \n > ".. getTime(os.time()) .. "\n \n for: \n > ".. reason "\n \n in the amount of: \n > ".. amount, arrestList)
if record then
table.insert(record,{plr.Name,officer.Name,reason,amount})
citationsDS:SetAsync(key,record)
else
local firstsave = {{plr.Name,officer.Name,reason,amount}}
for i,v in pairs(firstsave) do
for _,record in pairs(v) do
print(record)
end
end
citationsDS:SetAsync(key,firstsave)
end
end
-- retrieve the citation records for the given player
function database.GetCitationRecords(plr)
local key = keyprefix..plr.userId
local record = citationsDS:GetAsync(key)
if record then
return record
else
return {}
end
end
return database
So I’m not entirely sure what your script locations and the script types are anymore, though I remember having a similar issue to this (where prints after requires wouldn’t go off) a year ago before realising my fatal error:
LocalScripts don’t have access to the server, therefore if the location of your ModuleScript is an area that isn’t accessible by the client, then the LocalScript wont be able to get past the require stage. If you want your ModuleScript to be accessible by both the client and the server, it can’t be a descendant of services like “ServerScriptService” or “ServerStorage”. ReplicatedStorage is accessible by both the client and the server (which is why remotes and bindables are typically stored there), so parenting your ModuleScript to there may fix it.
If it doesn’t, at least this serves as a personal reminder.
Edit: Also might be helpful to check if your error resides in the TrelloApi or if you studio has (the name escapes me at this moment in time) the HTML thing enabled.
It turns out the issue was with the TrelloAPI.
Thanks to all who helped - it’s much appreciated!