John_ZM
(EOS)
April 17, 2025, 7:18pm
#1
Hi, I’m trying to get the folders, but something doesn’t work. I tried to serialize and deserialize them, but it didn’t work.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Packet = require(ReplicatedStorage.Libs.Packet)
event = Packet("event"):Response({
Folder1 = Packet.Instance,
Folder2 = Packet.Instance,
Folder3 = Packet.Instance
})
-- Client side
local folders = event:Fire()
-- Deserialize fire
local folders = event:Deserialize(event:Fire())
-- Server side
local folders = {
Folder1 = Instance.new("Folder"),
Folder2 = Instance.new("Folder"),
Folder3 = Instance.new("Folder")
}
event.OnServerInvoke = function()
return folders
end
-- Serialize invoke
event.OnServerInvoke = function()
return event:Serialize(folders)
end
1 Like
Hi there.
As far as I know everything automatically gets serialized and deserialized with Packet.
So all you have to do is remove the :Serialize()
and :Deserialize()
and it should work.
Also it’s best you just stay in the official Packet topic instead of redirecting to a new topic.
John_ZM
(EOS)
April 18, 2025, 3:19pm
#3
I tried not using serialize and deserialize and nothing works.
John_ZM
(EOS)
April 18, 2025, 3:22pm
#4
17:19:48.763 ReplicatedStorage.Libs.Packet:246: attempt to index nil with ‘Developer’ - Server - Packet:246
17:19:48.763 Stack Begin - Studio
17:19:48.764 Script ‘ReplicatedStorage.Libs.Packet’, Line 246 - function SerializeTable - Studio - Packet:246
17:19:48.764 Script ‘ReplicatedStorage.Libs.Packet’, Line 223 - function SerializeParameters - Studio - Packet:223
17:19:48.764 Script ‘ReplicatedStorage.Libs.Packet’, Line 339 - Studio - Packet:339
17:19:48.764 Script ‘ReplicatedStorage.Libs.Packet.Task’, Line 37 - function Call - Studio - Task:37
17:19:48.764 Script ‘ReplicatedStorage.Libs.Packet.Task’, Line 42 - function Thread - Studio - Task:42
17:19:48.764 Stack End - Studio
SharedEvents
local TitleEvents = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Packet = require(ReplicatedStorage.Libs.Packet)
TitleEvents.requestGetTitlesUi = Packet("RequestGetTitlesUi"):Response({
Survivor = Packet.Instance,
OG_Human = Packet.Instance,
Sponsor = Packet.Instance,
Meow = Packet.Instance,
Tester = Packet.Instance,
Developer = Packet.Instance
})
return TitleEvents
Server side
local TitleService = {}
TitleService.__index = TitleService
function TitleService.new()
local self = setmetatable({}, TitleService)
self.services = {
ServerStorage = game:GetService("ServerStorage"),
ReplicatedStorage = game:GetService("ReplicatedStorage")
}
self.titleEvents = require(self.services.ReplicatedStorage.Modules.Shared.Title.TitleEvents)
local uiPlayerTitles = self.services.ServerStorage.PlayerTitles.UI
self.uiTitles = {
Survivor = uiPlayerTitles.Survivor,
OG_Human = uiPlayerTitles.OG_Human,
Sponsor = uiPlayerTitles.Sponsor,
Meow = uiPlayerTitles.Meow,
Tester = uiPlayerTitles.Tester,
Developer = uiPlayerTitles.Developer
}
self:ConnectEvents()
return self
end
function TitleService:ConnectEvents()
self.titleEvents.requestGetTitlesUi.OnServerInvoke = function()
return self.titlesUi
end
end
return TitleService
Client side
local PlayerTitleGuiHandler = {}
PlayerTitleGuiHandler.__index = PlayerTitleGuiHandler
function PlayerTitleGuiHandler.new()
local self = setmetatable({}, PlayerTitleGuiHandler)
self.services = {
Players = game:GetService("Players"),
ReplicatedStorage = game:GetService("ReplicatedStorage"),
TweenService = game:GetService("TweenService")
}
local modules = self.services.ReplicatedStorage.Modules
self.titleEvents = require(modules.Shared.Title.TitleEvents)
self:RequestTitlesUi()
return self
end
function PlayerTitleGuiHandler:RequestTitlesUi()
self.titlesUi = self.titleEvents.requestGetTitlesUi:Fire()
end
return PlayerTitleGuiHandler
Here you are sending self.titlesUi
, which is nil.
I believe you want to send self.uiTitles
.
1 Like
John_ZM
(EOS)
April 18, 2025, 6:59pm
#6
I hate lua language because it is not strict
John_ZM
(EOS)
April 18, 2025, 7:13pm
#7
But in this piece of code self.titlesUi is empty
function PlayerTitleGuiHandler:RequestTitlesUi()
self.titlesUi = self.titleEvents.requestGetTitlesUi:Fire()
end
Yea but you set it to be what is on the server, so it works.
John_ZM
(EOS)
April 18, 2025, 7:30pm
#9
I send a request from the client to get a list of titles, the server returns the list, but the client does not receive anything
Have you tried printing self.uiTitles
on both the client and server? On the server print before returning, and on the client print after receiving and setting it.
John_ZM
(EOS)
April 18, 2025, 8:14pm
#11
Yes, I tried, the server says the full list is normal. It looks like this
["Developer"] = Developer,
["Meow"] = Meow,
["OG_Human"] = OG_Human,
["Sponsor"] = Sponsor,
["Survivor"] = Survivor,
["Tester"] = Tester
On the client {}
This is how the event is created
local TitleDataTemplate = {
Survivor = Packet.Instance,
OG_Human = Packet.Instance,
Sponsor = Packet.Instance,
Meow = Packet.Instance,
Tester = Packet.Instance,
Developer = Packet.Instance
}
TitleEvents.requestGetTitlesUi = Packet("RequestGetTitlesUi"):Response(TitleDataTemplate)
John_ZM
(EOS)
April 18, 2025, 8:21pm
#12
The list of these titles is on ServerStorage. Maybe they should be in ReplicatedStorage?
John_ZM
(EOS)
April 18, 2025, 8:28pm
#13
Yes, the problem was in ServerStorage
Solution is: Move your instances or someting else to ReplicatedStorage