RemoveEvent:FireClient() takes a player as the first argument. This is the client that will "receive the event" if that makes sense.
RemoveEvent.OnClientEvent() already knows who that player is (it's the local player who is listening to that event) and therefore, does not have have it as an argument. But it does have everything that was passed after that. (In your case nothing was, so it was nil, which is why your text came out that way)
For example, passing "Hello, world!" after specifying which client you want to fire for like so:
RemoveEvent:FireClient(player, "Hello, world!")
Will be handled like so in the local script:
RemoveEvent.OnClientEvent:Connect(text)
print(text)
end)
Based on what you're trying to do, I am assuming you want all the players' Gui change based on whoever clicks the brick. For that, there is a handy member function of RemoveEvents, which is :FireAllClients(). Since you're sending a signal to all clients, you do not need to specify a specific one. Just pass in the arguments directly.
So for your case, this how it would look like:
script.Parent.MouseClick:Connect(function(player)
game.ReplicatedStorage.RemoteEvent:FireAllClients(player.Name)
end)
Here is your Gui script:
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(name)
script.Parent.Text = "the food has been found, and ".. name.." found it"
end)
I would recommend reading up on the API references for RemoveEvents here:
https://developer.roblox.com/en-us/api-reference/class/RemoteEvent
2 comments
Wow!! I really understand it more now!! Thank you for the help!
No problem, glad I could help!