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

Changing an anonymous function into a regular one gives me an error?

Asked by 4 years ago
Edited 4 years ago

So I am making my customizable and editable admin commands and the way I do it is by anonymous functions. However I always want there be a way to get a player or a team so I turn them back to regular functions but that gives me an error.

The error is:

CommandsModuleScript:106: Expected '(' when parsing function, got 'GetPlayer'

Here's the anonymous function that was correct back then:

function(PlayerChatted, ReformedSplices) -- 
    print("Executed")
    if TeamsService:FindFirstChild(ReformedSplices[1]) then
        return {TeamsService:FindFirstChild(ReformedSplices[1])}
    end
    return nil
end,

Here's the regular function that is somehow incorrect:

function GetPlayer(PlayerChatted, ReformedSplices) -- error happens here
    print("Executed")
    if TeamsService:FindFirstChild(ReformedSplices[1]) then
        return {TeamsService:FindFirstChild(ReformedSplices[1])}
    end
    return nil
end,

The functions both have other anonymous functions above them inside of a table to keep things organized but I'm not sure why it causes that error. The error seems like it wants to become an anonymous function but I'm not too sure.

2
Have you tried GetPlayer = function(PlayerChatted, ReformedSplices)? y3_th 176 — 4y
0
yup it worked! post this as an answer so you can get the reward and other people won't come to the question anymore 123nabilben123 499 — 4y

Answer this question