Hi!, I would like to know how can i index the local player in a script, or any other alternatives. So I need some help.
Scripts canât get a LocalPlayer, but you can use PlayerAdded to get a player when they join.
game.Players.PlayerAdded:Connect(function(player)
print(player.Name .. " has joined the game!")
end)
So actually Iâm making a proyectile script, I wanted to index the local player that fired it.
If this is through a remote event get the player from OnServerEvent
, remember that the server has no concept of âlocal playerâ so it is not correct to refer to a player as a âlocal playerâ in the context of server.
Yes itâs from a remote event, so your saying I can âindexâ the âlocal playerâ through an argument?
The first arguement that is passed to the remote event is the Player object, you can access it like
local someEvent = game.ReplicatedStorage.someEvent
someEvent.OnServerEvent:Connect(function(player)
print(player.Name) <-- Should print the player who fired it
end)
Yes, it worked !! , thanks @MayorGnarwhal @sjr04 @WaterJamesPlough !
Instance, not object.
An instance is a specific representation of an object.
An object is a generic thing while an instance is a single object that has been created in memory.
Usually an instance will have values assigned to itâs properties that differentiates it from other instances of the type of object.
Sources:
Oh, I learnt the difference properly now. Thanks