Filtering Enabled

Explains to you what it is, and how to avoid it from breaking your script.

by caiomgt

Author Avatar


Recommended to have a bit of knowledge in lua, and an understanding in events and functions

Welcome! Today, we're going to learn Filtering Enabled, what it does and how to avoid it from breaking your script. So, Roblox has a weird system where there's a client(you, the player, playing the game, localscripts are ran in the client.) and the server(where the game lives, scripts are ran in the server), and, back then, whatever you did inside your client would also happen in the server(this is called replicating, replicating from client to server still happens through stuff like animations), this opened a huge possibility for hackers to potentially destroy whole servers. I dont think we want that so Roblox decided to come up with something else.

What is filtering enabled?

So, as we read above, Roblox came up with something, but what you may ask?

Well, filtering enabled...

So, remember that stuff where it would clone whatever happened in the client to the server? Gone that, now, only the server can replicate to the client. That means, whatever you do inside your client will not appear in the server, thus, not happening for anyone else but you. This means that hackers couldnt just go around, mess with their whole games and mess the server up too, filtering enabled was made to prevent that. Now, what if we want to do something with guis, that use local scripts and want to pass out something to the server, what do we do?

Working with filtering enabled

(note, these methods could still be tampered by hackers so its recommended for you to add checks) So, continuing from above, roblox made some new thingies so that local script to script communication would still be possible, which is through remote events/ functions. So, you may ask, what is the difference between remote events and remote functions?

calm down, im literally about to explain that... So, to start off, we'll talk about:

Remote Events

Remote events are kinda like normal events, but you can make your own and you can fire them whenever you want, they are used between server and client communication. You could also only fire for one client, the server or all clients. How? They have some little functions to help us out with that:

--Local Script
myRemoteEvent = Wherever your remote event is here

So, here we are firing to the server, which means, an event will fire on the server. It also supports you giving it arguments, however much you want. Now, we will get to receiving that in the server:

--Normal Script
myRemoteEvent = Again, remote event location here
myRemoteEvent.OnServerEvent:Connect(function(plr, yourArguments) 
    --Note, the player is always the first argument, then comes 
    --your own

You may have noticed: wait a minute, where did the plr argument come from? Well, its because, when you fire to the server, the RemoteEvent will always give you the player that fired it, then your arguments you've specified earlier. Now, we will send information from a normal script to a local script: Before we start, the server wont know which player to fire the remote event to(this problem doesnt happen when you fire to all clients, for obvious reasons.), so, we will have to get the player through whatever way we want so we can fire it:

--Normal Script
myRemoteEvent = you get it by now...
player = "Assume i got the player here"
myRemoteEvent:FireClient(player, myArguments)

--Local Script
myRemoteEvent = yep
    print("Look, the remote event fired to me :D")

And, you could also fire to all clients:

myRemoteEvent = im running out of stuff to put here

Receiving the remote event is the same as the one above. We're kinda done of remote events, so lets move on to:

Remote Functions

Well, remote functions are really similar to remote events, but, they need something to be returned so that the script can continue running, this can be useful sometimes for like a check, however, you want to be sure you return something, or else the rest of the script that called it wont run. To fire and listen to calls are a bit different, only a few keywords change but you just need to return something, example:

--Local Script
myRemoteFunction = insert location here
myValue = myRemoteFunction:InvokeServer()
print(myValue) --output: "Yes"

--Sever Script
myRemoteFunction = stuff
function myFunction()
    return "Yes"
myRemoteFunction.OnServerInvoke = myFunction
--You need to follow this format for RemoteFunctions, not sure if you can use anonymous functions

Now, my script is useless but you could do all sorts of different stuff with remote events and functions. The tutorial's pretty much done, but, i have a challenge for you: Try making a value change in the server with a remote function, then return how much the value is now .

Have a fun programming session with your new knowledge, Caio's signing out!

View in-game to comment, award, and more!