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

Hey, I'm new dev and I want to learn Remote Events. Any Idea where? [closed]

Asked by 4 years ago

Basically what is the title xD I just want to learn some Remote events cuz when using local script to update stats or values it's only effect specific user and doesn't help me :( Also I want to know lol

0
I tried this site really useless for me.. AmirGavron -2 — 4y
0
Well, the developer page of roblox is the best place to learn codes. Also, their examples are very easy too. BestCreativeBoy 1395 — 4y

Closed as Primarily Opinion-Based by IAmNotTheReal_MePipe, Cynical_Innovation, Dovydas1118, and WideSteal321

This question has been closed because it is a discussion about a topic focused on diverse opinions, which isn't a good fit for our Q&A format.

Why was this question closed?

2 answers

Log in to vote
1
Answered by 4 years ago

A remote event is a remote that scripts from either the local or server can communicate with. You put them in ReplicatedStorage.

Here is an example of a local script communicating to the server:

-- LocalScript (In the player's PlayerGui)

local Remote = game:GetService("ReplicatedStorage").RemoteEvent
-- Lets make the server print something when the player presses a button!

script.Parent.MouseButton1Click:Connect(function() -- Presses button
    Remote:FireServer("text") -- We are firing the remote which the server picks up. You can put anything in the arguments. In this case, we are delivering a string which the server will print out.
end)
-- ServerScript (In the ServerScriptService)

local Remote = game:GetService("ReplicatedStorage").RemoteEvent

Remote.OnServerEvent:Connect(function(message) -- The function will pick up the message from the remote. The argument is the string we said in the LocalScript.

    if message == "text" then -- we need an if statement to make sure a hacker didn't change the argument from the LocalScript.
        print(message) -- prints out message
    end
end)

It is vice versa if you are trying to communicate from the server to the client. The only downside to remotes is that hackers can change the arguments and they can fire it repeatedly or delete the line that fires the remote if it is in the LocalScript. This is my first answer :D

Ad
Log in to vote
0
Answered by 4 years ago

To understand RemoteEvents and Remote Functions , you need to understand how to server works, how it sends messages from the client to the server and vice versa.

It is good to store them in Replicated Storage.

Client To Server Example: When Local Player drinks a potion to make himself invisible, a RemoteEvent will help tell the server "Hey, make this player invisible to everybody else."

--In local script, AFTER the player has finished drinking his potion

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

-- Fire the remote event
remoteEvent:FireServer()

After the remote event has fired, in another script parented to serverscriptservice:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
remoteEvent.OnServerEvent:Connect(function(player) --ALWAYS add this player parameter, it refers to which player called the event
    --stuff to make player inivisible.
end)

If you do not use a remote event, only the local player can see that he's invisible, but others would still see that he's not invisible.

i hope this helps.

above you mentioned that https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events was useless for you. I was actually just replicating the same information to here. If you understand this, reread that article again and again until you understand. Also you could check out tutorials on YouTube.