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

Question about the plr argument in FireClient?

Asked by 6 years ago
Edited 6 years ago

Ok, so with FireClient, the first argument must be the player, right? Well, I'm having some issues. Ok, so lets say I run this in a server script

game.ReplicatedStorage.RemoteEvent:FireClient(plr,"one","two")

and in the localscript, the code would be

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(plr,1,2)
print(plr,1,2)
end)

the output would be (one two nil) and if I try to remove player it fails to cast value (or something like that) and I really need it to pass player, which it isnt doing.. ive tested it in the normal command bar, studio solo mode, and Clients and Servers mode they all return plr nil. any help?

PLEASE DO NOT SPOON FEED ME.

0
Can't pass the player in OnClientEvent. User#19524 175 — 6y
0
I thought it was required? OldSoul04 13 — 6y
0
It's required in FireClient, not OnClientEvent. User#19524 175 — 6y
0
so whats the point of passing player as an argument in FireClient but you cant use it in OnClientEvent?? OldSoul04 13 — 6y

1 answer

Log in to vote
0
Answered by
yyyyyy09 246 Moderation Voter
6 years ago

Alright I'll try to make this quick and easy to understand

game.ReplicatedStorage.RemoteEvent:FireClient(plr,"one","two")

The first Parameter is the player for when you want to fire an event to a single player, that single player is in your code defined by "plr".

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(plr,1,2)
    print(plr,1,2)
end)

The plr is not sent to the function here, it's just a parameter the FireClient event uses to define which player to send "one", and "two".

instead you would want to write this

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(1,2)
    print(game.Players.LocalPlayer,1,2)
end)

game.Players.LocalPlayer gets the player that is running the LocalScript

Ad

Answer this question