Lua Problem

so I want to save the the output of what ever a player says after /report in a variable. I can easly return it like this


function ISaid( ply, text, public )
    if (string.sub(text, 1, 7) == "/report") then--if the first 4 letters are /all continue
        return string.sub( text, 8 );--add [Global] infront of the players text then display
    end
end
hook.Add( "PlayerSay", "ISaid", ISaid );


, but I have no ide how to save the ouput in a variable so I can use it later. any ideas?

return statements can’t be used that way since it’s a hook. I would either use a net message or a single global variable depending on how you will be using it.

Or I’m completely wrong and no one is telling me why :v:



variable = ""


function ISaid( ply, text, public )
    if (string.sub(text, 1, 7) == "/report") then --if the first 4 letters are /all continue
        variable = string.sub( text, 8 ) --add [Global] infront of the players text then display
    end
end
hook.Add( "PlayerSay", "ISaid", ISaid )