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

How do I do this with RemoteFunctions/RemoteEvents? (FE)

So, i'm trying to make a script-executor type GUI. I've been trying to get this to work for hours, but i cant seem to get it to work. I want a server-side script to execute whenever you press a button in your GUI. Does anybody know if this is possible, or how to do it? The game is filtering-enabled due to the new Roblox update. Thanks,

-ItzStreamBot

Under my button in the GUI i have (in a localscript):


local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteVent = ReplicatedStorage:WaitForChild("RemoteVent")

script.Parent.MouseButton1Click:connect(function() remoteVent:FireServer(script.Parent.Parent.Input.Text) end)


The remoteevent is named "RemoteVent"

1 answer

OLD

You would create a RemoteEvent in the ReplicatedStorage, declare it in both a server script and your local script, and then do RemoteEvent:FireServer(data) from the local script and have the event trigger in the server script with RemoteEvent.OnServerEvent:Connect(function(player, data) ...end) .

The wiki explains how to do this: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

OLD

Filtering Enabled Filtering enabled at it's most base form is a disconnection between the Client and the Server. The client side of a game uses Local Scripts as well as Module Scripts, while the server side uses Scripts and Module Scripts. A Local Script will NOT work on the server side. Also as a side note you cannot use game.Players.LocalPlayer in a Script, it only works in Local Scripts. When Filtering Enabled is active, you cannot change anything on the server side from the client side, and you cannot change anything on the client side from the server side.

Server - Client Communication In order for the server and client to communicate, you need to use RemoteEvents and RemoteFunctions (link found at bottom). These allow you to talk between the two sides by passing information and data back and forth. Note that you cannot pass any Instances between the functions only Booleans, Numbers, Strings, Tables, Vectors, CFrames, and a few others, but those are the most commonly used. Futher on RemoteEvents and RemoteFunctions - RemoteEvents fire an event to one of the two sides passing values, but not returning anything. RemoteFunctions on the other hand pass values, and also return a value.

Quick Note RemoteFunctions and RemoteEvents are most commonly placed in the ReplicatedStorage since it is shared by both the Server and the Client, so both are able to see it and use it.

Ex. I cannot create a part and move it on the client side, it would only replicate for the one client - not the entire game.

Client You are a client, all players are considered clients. Each client has their own version of the game. Anything that happens on the client side of things does NOT replicate to the other clients or the server (aside from things like player owned physics, that replicates).

Client Sided Examples: ReplicatedFirst, PlayerGui, ReplicatedStorage

Server The server own it's own copy of the game, anything that happens on the server is replicated to all clients, meaning every person in the game will be able to see it.

Server Sided Examples: Workspace, ServerScriptService, ServerStorage, ReplicatedStorage, Character

In Terms of Security Anything on the client side can be looked at and taken by exploits. Since the client creates it's own version of the game, they can do whatever they want with it. That is why it's extremely important that you don't keep any important information on the client side.

Ex. If I had a Module Script on the client side that gave players money. An exploiter could look at that Module Script, determine which function you're using inside the module script as well as what parameters it takes, and then utilize it to give their self money.

Helpful Links

https://wiki.roblox.com/index.php?title=API:Class/Workspace/FilteringEnabled https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events http://robloxdev.com/articles/Experimental-Mode

5 comments

0

Thanks! I had already tried that, but this explains it better. Ill try!

0

Hm, i cant figure out how to define "data". I tried "local data = (script.Parent.Parent.Input.text)" but that didnt work. Any ideas?

0

Gonna completely repost my answer to Filtering Enabled explaination

0

Workspace isn't server side only. Don't feed OP bad information.

0

I meant it as you would need to change something in the Workspace server side in order for it to replicate to all clients.

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