So since you said use them, I’m assuming you know what they do, so I’ll smooth that over.
RemoteEvents can be triggered and used in several ways. Using:
MyRemoteEvent:FireServer()
and
MyRemoteEvent:FireClient(plr)
Now you can only fire the server via a LocalScript, and you can only fire the client via a ServerScript. When firing a RemoteEvent, you have the choice to send over information within the parenthesis. Now once those events are fired, you can use functions to check if they are fired, examples below.
MyRemoteEvent.OnServerEvent:Connect(Function(plr, gameProccessedEvent) --Those 2 variables are always preset, it gives you the Instance (This is important) of the player, and something else which doesn't matter too much atm.
end)
MyRemoteEvent.OnClientEvent:Connect(Function()--There will be no preset Variables here.
end)
Those are the basics.
When sending something to the client, you need to specify the player Instance, such as.
Example:
Script
script.Parent.Touched:Connect(function(hit)
myPlayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
end)
MyRemoteEvent:FireClient(myPlayer) --Specifies the player
You can send information within RemoteEvents as such
LocalScript
local Hi = true
local Instance = game.Workspace.Part2
MyRemoteEvent:FireServer(Hi, Instance) --Names the Variables and sends them
Now I can interpret these as such.
ServerScript
MyRemoteEvent.OnServerEvent:Connect(function(plr, HiVariable, InstanceVariable)
print(HiVariable) --Will return true
print(InstanceVariable.Name) --Will return the name of the instance.
end)
Roblox addresses ways of using Remote Events in this article.
Feel free to ask questions, I hope this helped.