Making a return function.

Hey guys, sorry I’m stupid and can’t figure this out.
I’m pretty sure i’m doing it completely wrong but i’m trying to make a function that returns true if the player is holding down up,left,down or right and false if not



// in shared.lua
function CHECKMOVEMENT() 
    local ply = LocalPlayer()
    if (ply:KeyDown(IN_FORWARD) || ply:KeyDown(IN_BACK) || ply:KeyDown(IN_MOVELEFT) || ply:KeyDown(IN_MOVERIGHT)) then
    return true
else
    return false
    end
end


Error.



Hook 'SPRINTACC' Failed: [gamemodes
l\gamemode\init.lua:34] attempt to call field 'CHECKMOVEMENT' (a nil value)


Your script will not work on the server, why bother placing it in shared.
-snip- nvm the tabbing was weird so I didn’t see that the code would actually work

If you’re for looking to do a metafunction and call it like ply:CHECKMOVEMENT() you should do it like this:

[lua]
local meta = FindMetaTable(“Player”)
function meta:CHECKMOVEMENT()
if (self:KeyDown(IN_FORWARD) || self:KeyDown(IN_BACK) || self:KeyDown(IN_MOVELEFT) || self:KeyDown(IN_MOVERIGHT)) then
return true
else
return false
end
end
[/lua]

Thank you, it worked.