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

Would this work?

Asked by 10 years ago
game.Players.PlayerAdded:connect(function()

    function Leaderstats()

    end

    function PowerLevel()

    end

    function Attack()

    end

    function Defense()

    end

    function Agility()

    end

    function Rank()

    end

    Leaderstats()
    PowerLevel()
    Attack()
    Defense()
    Agility()
    Rank()  

end)

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Yes, this would work. It's usually considered bad practice to define functions inside other functions, because it can lead to confusing results & poor performance -- but it's okay to do.

It can also be considered useful since it hides the functions from other contexts.

A warning: Defining functions is very slow. While it's not a problem for something like PlayerAdded, since it will happen at most a few times a minute, if it's something happening a lot -- it's better to reformat to avoid that.


A PlayerAdded even without the parameter isn't very useful, don't forget it

0
Oh yeah I forgot the player inside (), Thanks! BosswalrusTheCoder 88 — 10y
Ad

Answer this question