What is return and how often do we use it in roblox?( please give an example too)
addNumbers = function(x, y) return x + y end print(type(addNumbers)) -- why does this print function
function PlayerAdded(p) -- why is there a p as an argument, do we really need it there? print(p.Name) end game.Players.PlayerAdded:connect(PlayerAdded)
function addNumbers(x, y) return x + y end print(addNumbers(1+2)) -- should print 3
function PlayerAdded(p) -- why is there a p as an argument, do we really need it there? print(p.Name) end game.Players.PlayerAdded:connect(PlayerAdded)
The PlayerAdded event returns the Player that is joining. the p in the event is the argument for the Player that can be referenced in the function as you did with p.Name