Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Few more questions?

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)


1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.