#FireClient Question
1 messages · Page 1 of 1 (latest)
you probably have an object value in the table
if i remember correctly remote events can't send objects from the server to the client
i forgot the exacts but i think it's cause it has to exist on both the server and the client for it to work
here's my code btw forgot to post it
local DSM = require(game.ServerScriptService.Init.DataStoreManager)
local RS = game:GetService("ReplicatedStorage")
local HTTPS = game:GetService("HttpService")
local Player = game:GetService("Players")
local admins = require(RS.Modules.Init.Admins)
local adminRemote = RS.Remotes.Misc.Admin
local updateText = RS.Remotes.Misc.UpdateAdminText
local module = {}
local function updateGUI(data, id)
updateText:FireClient(data, id)
end
function module.find(p, text)
local cmd = string.split(text, " ")
local ds = DSM.find("Players", cmd[2]) or DSM.hidden("Players", cmd[2])
local response = ds:Open()
if(response == "Success") then
print(ds.Value.Element)
local data = ds.Value
local id = cmd[2]
local jsonStringData = HTTPS:JSONEncode(ds.Value)
local jsonStringID = HTTPS:JSONEncode(cmd[2])
updateGUI("hello")
else
local jsonStringID = HTTPS:JSONEncode(cmd[2])
updateGUI("Could not find player: ", jsonStringID)
end
wait(2)
if ds.Hidden == true then
ds:Destroy()
end
end
adminRemote.OnServerEvent:connect(function(p, cmd, text)
if(module[cmd]) then
module[cmd](p, text)
end
end)
i was trying to send the table of information I have in a datastore to the client. All the elements are strings in there
yes, you can send tables using :FireClient
remoteEvent:FireClient(player, {TestString = "Test" })
remoteEvent.OnClientEvent:Connect(function(table)
print(table)
end)
``` tho you cannot send instances nor functions using tables with remote events
you cant fire a client with a string, you are passing the string "hello" and then using it as to fire a client, it has to be a player instance
do
updateGui(p, "hello")
oh oops forget the "hello" i was trying to pass in the jsonencoded stuff
i think p states for player
ok so pass in the player
ok ill pass in the player and see if that works
what i wanted to pass in was updateGUI(jsonStringData, jsonStringID)
but you need a player
you cant use
:FireClient()
without providing a player instance
should be
:FireClient(player, dataTable)
local DSM = require(game.ServerScriptService.Init.DataStoreManager)
local RS = game:GetService("ReplicatedStorage")
local HTTPS = game:GetService("HttpService")
local Player = game:GetService("Players")
local admins = require(RS.Modules.Init.Admins)
local adminRemote = RS.Remotes.Misc.Admin
local updateText = RS.Remotes.Misc.UpdateAdminText
local module = {}
local function updateGUI(player, data)
updateText:FireClient(player, data)
end
function module.find(p, text)
local cmd = string.split(text, " ")
local ds = DSM.find("Players", cmd[2]) or DSM.hidden("Players", cmd[2])
local response = ds:Open()
if(response == "Success") then
print(ds.Value.Element)
local data = ds.Value
local id = cmd[2]
local jsonStringData = HTTPS:JSONEncode(ds.Value)
local jsonStringID = HTTPS:JSONEncode(cmd[2])
updateGUI(p, dataTableYouWantToSend)
else
local jsonStringID = HTTPS:JSONEncode(cmd[2])
updateGUI(p, dataTableYouWantToSend)
end
wait(2)
if ds.Hidden == true then
ds:Destroy()
end
end
adminRemote.OnServerEvent:connect(function(p, cmd, text)
if(module[cmd]) then
module[cmd](p, text)
end
end)
you got it working?
it worked!
thank u so much i was just starin at it for so long