Ok how can I fire a remote event from local script and make it run for 1 player on server?
local player = game.Players.LocalPlayer game.ReplicatedStorage.RemoteEvent:FireServer(player)
server
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() print("aa") end)
when you call FireServer
, the function fires the OnServerEvent
signal with the player that called the FireServer
, and all extra arguments that you pass to FireServer()
.. therefore, you don't need to do FireServer(player)
, b/c the engine does it automatically for you.
so the following should hopefully answer ur question:
LocalScript:
game.ReplicatedStorage.RemoteEvent:FireServer()
Server script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) print(player.Name," fired the server") end)
keep in mind that LocalScripts are "local" to a player.. they run on a player's computer.. they are meant to handle all the client(player) sided things..
It's not possible to do something for one player on the server. Here is everything in a nutshell (hopefully):
Server: Every action that happens here happens for everybody in-game. If you want a server script, put it in the ServerScriptService
.
Client: Scripts and other actions that happen here only happen to the local player, or the client. To do things on the client, put a local script in StarterPlayer
, StarterGui
, etc.
For more information about clients and servers, visit this website: https://developer.roblox.com/en-us/articles/Roblox-Client-Server-Model