Hello!
So I want to make a project for fun.
But I have a question. And that question Is: How do I mention the player In a server script?
I’m stuck with this question for like 2 hours. So I would like an reply.
Thanks and have a nice day! ![]()
Hello!
So I want to make a project for fun.
But I have a question. And that question Is: How do I mention the player In a server script?
I’m stuck with this question for like 2 hours. So I would like an reply.
Thanks and have a nice day! ![]()
Review about remote events, it’s a client to server communication.
I don’t see anything related to mentioning the player In a server sided script.
I suggest using game:GetService(“Players”).PlayerAddedConnect(function(player)``` function to check the player.
Here is the documentation.
What exactly are u using this for?
Assuming the server script is somewhere inside the player you can do
local Player = script.Parent.Parent.Parent etc
and with Remotevents you can get the player by
--Client Side
RemoteEvent:FireServer("Wassup")
---Server Side
RemoteEvent.OnServerEvent:Connect(function(Player, Arg)
print(Player, "said", Arg) --- Prints "Playernamehere said wassup"
end)
or if you want to mention the player when they join you can do what @octav20071 recommended
game.Players.PlayerAdded:Connect(function(Player)
print(Player, "Joined") --- prints "Playernamehere Joined"
end)
---Can also be done when they're leaving
game.Players.PlayerRemoving:Connect(function(Player)
print(Player, "Has Left") --- prints "playernamehere Has Left"
end)