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

I want to double check if I'm firing this remote event in a server script correct?

Asked by 4 years ago

I wanna double check if this is correct...

If I want to fire a remove event from a local script to local script is this what I do correct?

Local script:

game.ReplicatedStorage.EventName:FireServer()

Script:

game.ReplicatedStorage.EventName.OnServerEvent:Connect(function(plr)
  game.ReplicatedStorage.EventName2:FireClient(plr) -- Firing to local script
end)

local script that wanted to be fired:

game.ReplicatedStorage.EventName2.OnClientEvent:Connect(function(plr)
end)

I want to see if I did the script correct for :FireClient()

AND if that player can only see it and not everyone. Thanks!

0
You should use prints to check JesseSong 3916 — 4y
0
That should be correct cadengamer11111 0 — 4y
0
if you fire from client to server then server to client straight after, there's no point in using a remote event, use it when you need to fire a specific client from the server, fire each client differently, or fire server from client Robowon1 323 — 4y

2 answers

Log in to vote
2
Answered by 4 years ago

Alright, so let me explain what you're doing. First, you're firing to the server. Then you're receiving that remote on the server, and firing back to the client, with the argument from the .OnServerEvent, which means you're firing the remote back only to the player that fired it to the server, and then you're receiving it on the client with .OnClientEvent. So for the first question, the only thing wrong is the .OnClientEvent argument, which is not the player, unlike .OnServerEvent. So it'd look like:

game.ReplicatedStorage.EventName2.OnClientEvent:Connect(function() -- first argument will be the first argument sent by :FireClient(), not the player
end)

And for the second question, the player will only see if you make those changes on the client, which you could do on the script that fires to the server, or on the .OnClientEvent. If you want to make everyone see, you could make the change on the .OnServerEvent, or you could do :FireAllClients() on the .OnServerEvent (:FireAllClients() do not need a player argument to be fired). I hope this helped you (if it wasn't confusing)

0
Bit confusing to read but I understood what you said. Thanks! TheBuliderMC 84 — 4y
Ad
Log in to vote
0
Answered by
RFL890 4
4 years ago
fuck
0
lmao User#32819 0 — 4y
0
great answer! TheBuliderMC 84 — 4y

Answer this question