Disabling Noclip if not correct job

Hi all,

On my server people who are in the group “admin” can use noclip when not on the correct job “Admin on Duty”. I have tried to disable it but it does not work and admins can still use noclip on other jobs.

Here’s the code I made:



hook.Add( "PlayerNoClip", "RestrictNoclip", function(ply)
	if ply:GetUserGroup() == "superadmin" or ply:GetUserGroup() == "community"
		return true
	end
	
	if !team.GetName( ply:Team() ) == "Admin On Duty" then
		return false
	end
	
end)


Thanks,
Computer600

In your post you say the job is Admin on Duty but in your code it says Admin On Duty. Lua is case sensitive, so you need to make sure that the case is correct. Alternatively, you can just use string.lower, which is what I did because I don’t know which version of the job’s name is correct. You shouldn’t use string.lower if you know the exact case of the string.

[lua]hook.Add( “PlayerNoClip”, “RestrictNoclip”, function(ply)
return string.lower(team.GetName(ply:Team())) == “admin on duty” or ply:IsUserGroup(“superadmin”) or ply:IsUserGroup(“community”)
end)[/lua]

If you’re going to use string.lower then you need to make the string to check for all lowercase.