Just do this:
event:FireClient(player,table)
--localscript
event.OnClientEvent(player,table)
--// etc.
end)
Just do this:
event:FireClient(player,table)
--localscript
event.OnClientEvent(player,table)
--// etc.
end)
huh, so how do I get my server script to the client. Im doing this for a spectate system which only spectates players in a round.
Then use a RemoteFunction instead.
Remote and Functions that are bindable are used for stuff that happen in game / live events it even says that on developer.roblox.com that it is used for live events
There are multiple options to send data back through scripts such as _G, shared, a value, module, etc.
Could you show an example. Thats the part Im stuck on.
Yes, But I CANNOT do _G since im doing it with a server and local sides.
_G is not recomended I tried this right here:
--serverscript
_G.Test = "Hello"
--other serverscript
print(_G.Test)
It did nothing
Here’s an example of using a RemoteFunction, but there are multiple methods to do this such as a ModuleScript inside ReplicatedStorage.
local listOfPlayers = {
'Player1',
'Player2'
}
local remote = game.ReplicatedStorage.GetPlayers
remote.OnServerInvoke = function()
return listOfPlayers
end
local remote = game.ReplicatedStorage.GetPlayers
local players = remote:InvokeServer()
print(players) --[[ ->
"Player1",
"Player2"
]]
I have used _G multiple times and it worked although I mostly use a ModuleScript for simple data such as tables with some strings.
im pretty sure _G isnt that safe, i’ve heard that somehwere
OnServiceInvoke isnt correct, its OnServerEvent
Wait, if your running that script on the client, then its OnClientEvent.
No, I’m running that script on a server but Im trying to send the table to the local script.
Oh, your not trying to recive events then, change it to FireClient
Wait, are you using .FireClient? If you are use :FireClient