Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to communicate between the server, like if the game is FilteringEnabled?

Hey all! (I know I start every question with that.) I'm a bit puzzled here. My game isn't FilteringEnabled, but it would be using the same methods, since I'd be editing another Player's Gui. I've checked the Wiki on the topic with RemoteFunctions and events, but I'm still a bit clueless. I've made attempts using the examples they provided, yet they never turned out right. I'm not trying to ask for a script, but maybe explain what to do? Possibly provide a line or 2 to get me started? Thanks for any help!

2 comments

0

what exactly are you trying to do?

0

@ImageLabel, For now, just put a GUI into another player's PlayerGui. Setting it up with a remote function

1 answer

✓ Accepted answer

I'm assuming you want a reference of how each objects work.


Remote Event

This fires directly to the intended entity.

  • CLIENT TO SERVER

  • :FireServer()

  • .OnServerEvent

-- LOCAL
RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")

RE:FireServer("hello")
-- SERVER
RE = Instance.new("RemoteEvent", game.ReplicatedStorage)

RE.OnServerEvent:connect(function(Player, Message) -- *
	print(Message)
end)

hello


  • SERVER TO CLIENT

  • :FireClient()

  • .OnClientEvent

-- SERVER
RE = Instance.new("RemoteEvent", game.ReplicatedStorage)

RE:FireClient("hello")
-- LOCAL
RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")

RE.OnClientEvent:connect(function(Message)
	print(Message)
end)

hello


Remote Function

This fires to the entity and is capable of returning back to its origin.

  • CLIENT TO SERVER

  • :InvokeServer

  • .OnServerInvoke()

-- LOCAL
RF = game.ReplicatedStorage:WaitForChild("RemoteFunction")

local Arg = RF:InvokeServer()
if Arg then
	print(Arg .. " returned!")
end
-- SERVER
RF = Instance.new("RemoteFunction", game.ReplicatedStorage)

function RF.OnServerInvoke(Player) -- *
	return 10
end

10 returned!


  • SERVER TO CLIENT

  • :InvokeClient

  • .OnClientInvoke

-- SERVER
RF = Instance.new("RemoteFunction", game.ReplicatedStorage)

local Arg = RF:InvokeClient()
if Arg then
	print(Arg .. " returned!")
end
-- LOCAL
RF = game.ReplicatedStorage:WaitForChild("RemoteFunction")

function RF.OnClientInvoke()
	return 42
end

42 returned!


In short, it's like any other functions and events. These objects just cross the server/client border.

I hope this answers your question!

*NOTE: Client to server communication means that an additional "player" argument will be included (first argument).

2 comments

0

Thank you very much!

0

You're welcome

This discussion is preserved as it was. New answers, comments, and votes are closed.