You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want to understand how to use remote events and remote functions
What is the issue? Include screenshots / videos if possible! I’m unsure how the remote events and remote functions work
What solutions have you tried so far? I tried looking for videos on youtube but i’m still confused
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
So i watch a youtube tutorial on bindable events and functions and at the end i still don’t understand how they work or how to use them can someone please explain thanks for your help.
RemoteEvents allow for server-client communication, so for example, you want to change something on the server from the client, RemoteEvents are the way to go.
You want to learn this? Okay it’s pretty easy. Let’s say you want to make a part appear only for one player, while others don’t see it. Alright, first insert a remoteevent in replicated storage(important) then, I will make server tell client to insert a part of it’s first player.
Remember the remoteevent path? Good. Let’s now go to scriptingpart.
--wherever this should be but
-- must be server.
local remote = game.ReplicatedStorage["YOURREMOTENAME(CASESENSTIVE)"]
game.Players.PlayerAdded:Connect(function(plr)
if #plr < 2 then
remote:FireClient(plr)
end
end)
Will that magically put that block only for this specific player yet? Ofcourse not. Because we need a localscript too.
--localscript
local remote = game.ReplicatedStorage["YOURREMOTENAME(CASESENSTIVE)"]
remote.OnClientEvent:Connect(function()
Instance.new("Part",game.Workspace).Anchored = true
end)
Tadah! A part is only inserted for you, for more stuff, read the documentation cuz I didn’t explain everything other than server > client communication, it can also do client to server communication even server to all client communication which is especially useful for smooth tweening! Read it here.
Roblox, understandably, works under a fairly-traditional client-server model. This means when you play a game on Roblox, you are experiencing it on your machine alone, and the necessary information is replicated to it. The same is true both ways- your machine needs to manually pass important information to the server for it to use.
RemoteEvents and RemoteFunctions work as a type of information proxy across the disconnect created by this model. Under this model, the server cannot know exactly what a client has done and what changes to sanity check (although there are some interesting caviats with UI element methods activating anyways). Likewise, if a client is supposed to cache some new data that the server decided they should have- there is no way to do that without battling this disconnect. This isn’t to say that RemoteEvents and RemoteFunctions are the end-all be-all of replication, but to a beginner they can react to the disconnect appropriately.
In time you will learn what to be careful of and better habits, but as a traditional setup let’s look at this:
--@ ServerScript
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("RemoteEvent")
Event.OnServerEvent:Connect(function(...)
print("Nothing much!")
end)
-- @ LocalScript
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("RemoteEvent")
Event:FireServer("What's up, server?")
You can accomplish this elsewhere technically, but it is my understanding that most games hold a majority of their remotes inside of ReplicatedStorage (because as the name would suggest, it is equally digestible game information to both ends of this model).
It’s a pretty normal part of game development, and absolutely worth dropping some research into fully understanding.