So I useally script like without the whole FE but how would i script whats the difference?
How to make scripts usable on a filtered enabled game?
1 answer
Hello, the main reason to always use FilteringEnabled is game security. Without it your game could be easy hacked and a hacker could do a lot of bad things to your game. Why?
In Roblox there are two main scripts types: Server script and Local script. Server script do all operations for server game logic (for example teleport players, open doors and other) and Local script do all operations for player (for example play music in your local computer). Local script is processed in the players own computer, not in Roblox server. Without FilteringEnabled you can manipulate form Local script the main game logic. For example you could insert dragon object from local script and this dragon would be replicated to all players, so this really bad thing. Without FilteringEnabled you could directly access and manipulate you game logic in server side. Also Server script can easy and directly access players Local scripts and things which it needs (for example server could say play music for this player). So in several words you could do manipulations from local script to server and from server to local script directly.
And here comes FilteringEnabled capability. When you turn on FilteringEnabled the server and players are protected. So if you create a dragon object in Local script and try to insert it into workspace, the dragon object will only be in your computer. Dragon object will not be inserted into main server and not to be replicated to other players. So every are safe now. Only you in local computer will see this dragon. So the dragon can not do any damage to game. Also then FilteringEnabled server scripts can not access players Local script directly (For example play music like before).
So now you know, what is FilteringEnabled and I will explain how to program with it :) Also you could read more about FilteringEnabled here in more details: http://wiki.roblox.com/index.php?title=FilteringEnabled_with_the_Client-Server_Model
Programming with FilteringEnabled is easy, just a little different. You should think differently :) When FilteringEnabled is on, to do all things which you do before, you should use RemoteEvents and RemoteFunctions. You should think in this manner - all things connected with server can only change server and all things connected this player local script can only change player computer (local script only). So for example in your local script you need change house color from red to green, you should ask server to do this. And in the other hands, when your server wants to play music for player, the server should ask local script to play music for player. We can achieve this using RemoteEvents and RemoteFunctions. Idea is simple you should create a function in your server which will change your house color from red to green and just call this function from your local script. That' s all. And in the other hand you should create function in local script which will play music, when server ask it. But remember you can not access direct these functions. To access function you should use RemoteEvent or RemoteFunction. Use RemoteEvent, when you do not need return anything. Use RemoteFunction, when you need return something like in simple function.
Here is simple server event example:
-- Inside Server Script
local event = Instance.new("RemoteEvent") -- creates the event object
event.Name = "MyServerEvent" -- giving a name to the event so we can fire it specifically elsewhere
event.Parent = game.Workspace -- puts the event into the Workspace
event.OnServerEvent:connect(function() -- define the function that will be called when the event is fired
-- this is where you put all the code you want to run when the event is fired
game.Workspace.Baseplate.BrickColor = BrickColor.Random()
end)
-- Inside Local Script
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = game.Workspace.ColorBrick
clickDetector.MouseClick:connect(function(hit)
game.Workspace.MyServerEvent:FireServer()
end)
Here is simple client event example:
-- Inside Server Script
game.Players.PlayerAdded:connect(function(player)
local event = Instance.new("RemoteEvent")
event.Name = "MyClientEvent"
event.Parent = player
wait(5)
event:FireClient(player)
end)
-- This is inside a LocalScript.
-- Place it anywhere a LocalScript can go (for example, under StarterPlayer.StarterPlayerScripts)
game.Players.LocalPlayer:WaitForChild("MyClientEvent").OnClientEvent:connect(function()
print("EventHappened")
end)
This code is taken form Roblox tutorial about RemoteEvent. Read more about RemoteEvents and RemoteFunctions in this link: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial
One more thing, then you test your game with FilteringEnable test it with server and several clients. (use test button in Roblox studio) not just play button. In this manner you will see that is really working. For example try to change brick color from red to green, when mouse button is pressed. You will see that color changed for one player, but not for another player. It is just for understanding. When you just want to test game you could test it with play button. But it will test you game only for one player.
So read these two link which I mention and you will become an expert in FilteringEnabled. Good Luck :) If you have additional questions, aks me, I will try to help.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
This really helped me thanks