FindMetaTable("Player") works only server-side

Hello.

In server-side, i made something like this (Example):




local meta = FindMetaTable( "Player" )

function meta:IsEx()
	return ex
end

ex = false

function exstart()
ex = true
end



I don’t know why, now I can use player:IsEx, only server-side, if I use it in client-side the console give me this error:

attempt to call method ‘IsEx’ (A nil value), like it doesn’t exist.

Am I doing it wrong?
Thank you!

You need to place that code in a clientside file. You have defined it for use on the server’s end, but not the client.

However, with what you’re trying to do, the variable ‘ex’ won’t be the same on the server and the client.
Check out

SetGlobalBool and

GetGlobalBool

Thank you, so I can do something like this:



local meta = FindMetaTable( "Player" )

function meta:IsEx()
	return ex
end

ex = false

function exstart()
ex = true
end

SetGlobalBool( exmeta, ex )


ClientSide



if GetGlobalBool( "exmeta", false ) then
print("yes it works")
end


Well, if all you want to do is retrieve a variable, I don’t know why you’re using it as a meta-function. You’d want something more like this



function IsEx()
    return GetGlobalBool("ex")
end

function SetEx(state)
    SetGlobalBool("ex", tobool(state))
end


in a shared file.

Then in the client, you could do



if IsEx() then
    print("hello")
end


Thank you!