Broken script

Seems that this script which i put in autorun of server in lua doesnt want to work. It properly prints in chat but will not do anything else.

local function AdminGod(ply)
	if ply:IsOnDuty() then
	ply:ChatPrint("AutoGod Enabled")
hook.Add("PlayerSpawn", "AdminGod", AdminGod)

Any suggestions?

Ps: IsOnDuty is a meta-function in the server.

Stop using bold text.

Probably something else calls GodDisable somewhere.

like in a core file? where it would be setting hp to the default?

I any custom lua file that you have installed on your server.
It is really easy to trace back though, if that indeed is the case, by simply detouring the metatable function and calling error(“test”) from it.

Im lost, the meta function works fine. If that’s what you’re trying to get to. Its the same on i use for a bunch of other things.

there is another place somewhere in your server files that is calling GodDisable() somewhere.

Is this DarkRP?

It is

DarkRP has a baby god system which gives you god mode for a short amount of time before disabling it to prevent/reduce spawn killing. Because you want permanent god mode, you’ll need to disable this for the player by doing something like this:

local function AdminGod(ply)
if ply:IsOnDuty() then
ply:ChatPrint(“AutoGod Enabled”)
local c = ply:GetColor()
timer.Simple(0, function()
if not IsValid(ply) or not ply.Babygod then return end
ply.Babygod = nil
ply:SetColor(Color(c.r, c.g, c.b, c.a))
timer.Destroy(ply:EntIndex() … “babygod”)
hook.Add(“PlayerSpawn”, “AdminGod”, AdminGod)

Oh I forgot about that, Im sorry haha i dont think about the simple things sometimes, Thanks