I am using Remote Events and running into an issue when it comes to using FireClient. Check out this code:
game.ReplicatedStorage.Example:FireClient()
As you probably know already in those () I need to define the Player because I am not using "FireAllClients". Well that is where the problem lies, how can I define who the current player is without using OnPlayerAdded.
This is on a server script so I cant use LocalPlayer, though I wish I could. Why is there nothing for ServerScripts to get the current client simply, how LocalPlayers does. I am surprised how difficult it is just to get the current player on a Server Script.
Any ideas? Thanks in advance!
Short Version: Kinda, but there isn't a way to do it without an Event
Long Version: There is no way to get the player through a server script without defining it through some sort of method. OnPlayerAdded is one of these methods. There are other methods though. For example, you could fire the event when another event is fired by the player. Something like this:
These scripts will Fire the same event once to the server, then once to the client
LocalScript
game.ReplicatedStorage.Example:FireServer()
ServerScript
game.ReplicatedStorage.Example.OnServerEvent:connect(function(plr) game.ReplicatedStorage.Example:FireClient(plr) end
so, basically, there's no simple way to define the player.