Hey everybody, i know this is probably a really dumb question but i am still pretty new to roblox scripting, and i am sorry if i explain this poorly, but i am trying to pass a player to a remoteevent to try to print the players name for testing purposes, obv., but when i try to pass the player to the remote event, i get this error: attempt to index nil with ‘Name’.
script:
local re = game.ReplicatedStorage.RemoteEvent
game.Players.PlayerAdded:Connect(function(plr)
re:FireClient(plr)
end)
localscript:
local re = game.ReplicatedStorage.RemoteEvent
re.OnClientEvent:Connect(function(plr)
print(plr.Name)
end)
The first argument to FireClient() is always the player. This argument is not passed to the connection as an argument for that. If you want to add the player as an argument to that, you can add a second argument to FireClient() like so:
script:
local re = game.ReplicatedStorage.RemoteEvent
game.Players.PlayerAdded:Connect(function(plr, plr)
re:FireClient(plr)
end)
localscript:
local re = game.ReplicatedStorage.RemoteEvent
re.OnClientEvent:Connect(function(plr)
print(plr.Name)
end)