Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Few more questions?

Asked by 10 years ago

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

Log in to vote
0
Answered by
jav2612 180
10 years ago
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

Ad

Answer this question