Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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!

0
what exactly are you trying to do? ImageLabel 1541 — 9y
0
@ImageLabel, For now, just put a GUI into another player's PlayerGui. Setting it up with a remote function Shawnyg 4330 — 9y

1 answer

Log in to vote
2
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

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).

0
Thank you very much! Shawnyg 4330 — 9y
0
You're welcome Redbullusa 1580 — 9y
Ad

Answer this question