#FireClient Question

1 messages · Page 1 of 1 (latest)

uneven hull
#

Is it possible to send a table through fireclient? Im trying to send a table of values to a client but I keep on getting the error message cannot convert value to object.

clear prawn
#

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

uneven hull
#

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

devout anchor
#

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
devout anchor
#

do

#
updateGui(p, "hello")
uneven hull
#

oh oops forget the "hello" i was trying to pass in the jsonencoded stuff

devout anchor
#

i think p states for player

uneven hull
#

ok so pass in the player

devout anchor
#

yes

#

you are now passing nor an instance nor a player instance

uneven hull
#

ok ill pass in the player and see if that works

#

what i wanted to pass in was updateGUI(jsonStringData, jsonStringID)

devout anchor
#

but you need a player

#

you cant use

#

:FireClient()

#

without providing a player instance

#

should be

#

:FireClient(player, dataTable)

uneven hull
#

ohhhh ok i see what u mean

#

alright ill pass in a player and check back in

devout anchor
#
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?

uneven hull
#

it worked!

uneven hull