Playermodels won't spawn with bodygroups

I am currently making a MilitaryRP and am using lots of models that require bodygroups for what I’m aiming to do. Below is what I currently have put under the model:


PlayerSpawn = function(ply) 
		ply:SetBodygroup(1, 3) 
		ply:SetBodygroup(2, 0) 
		ply:SetBodygroup(3, 3) 
		ply:SetBodygroup(4, 0) 
		ply:SetBodygroup(5, 0) 
		ply:SetBodygroup(6, 0) 
		ply:SetSkin(0)
		ply:SetHealth("100") 
	end,

If anybody has any solutions, I’m all ears.

Ehm…
Where is this code at?
How are you running it?
And also ply:SetHealth first argument is a number, not an string, so put instead 100.

This code is in my darkrpmodification-master/lua/darkrpcustomthings/jobs.lua

Here’s the full code for the job with the edit to ply:SetHealth that you said:



TEAM_MARINE = DarkRP.createJob("Marine Leisure",{
color = Color(0, 255, 0, 255),
model = {"models/player/sanic/marinedp.mdl"},
description = [[You are a Marine]],
weapons = {"tfa_bf4_aek971","tfa_deagle","tfa_tec9"},
command = "marinel",
max = 0,
salary = 50,
admin = 0,
vote = false,
hasLicense = false,
category = "Marines",
PlayerSpawn = function(ply) 
		ply:SetBodygroup(1, 3) 
		ply:SetBodygroup(2, 0) 
		ply:SetBodygroup(3, 3) 
		ply:SetBodygroup(4, 0) 
		ply:SetBodygroup(5, 0) 
		ply:SetBodygroup(6, 0)
		ply:SetSkin(0)
		ply:SetHealth(100) 
	end,
customCheck = function(ply) return CLIENT or ply:GetNWString("usergroup") == "marine" or ply:IsAdmin() end,
CustomCheckFailMsg = "You are not authorized to access this rank"
})


Try setting a timer for 0.1 secs

Can you possibly show me how to do so? I’ve never used timers before, and I’d appreciate just having it to copy/paste rather than having to mess around with it, possibly having to redo it multiple times.

timer.Simple

Theres a couple examples on the wiki.

The timer didn’t work. Is there anywhere specific it needs to be in the files? If so, where should it be?



PlayerSpawn = function(ply) 
	timer.Simple(.1, function()
		ply:SetBodygroup(1, 3) 
		ply:SetBodygroup(2, 0) 
		ply:SetBodygroup(3, 3) 
		ply:SetBodygroup(4, 0) 
		ply:SetBodygroup(5, 0) 
		ply:SetBodygroup(6, 0)
		ply:SetSkin(0)
		ply:SetHealth(100)
	end) 
	end,


So, that didn’t seem to work either. Could it possibly be something with mounted addons? I’m only asking because I have sound issues with certain addons because of this.

As long as you’re able to see the model I don’t think so. If it comes down to it here’s a really ghetto fix.



hook.Add("PlayerSpawn", "BodyGroupsYo", function(ply)
	if ply:GetModel() == "models/player/sanic/marinedp.mdl" then
		ply:SetBodygroup(1, 3) 
		ply:SetBodygroup(2, 0) 
		ply:SetBodygroup(3, 3) 
		ply:SetBodygroup(4, 0) 
		ply:SetBodygroup(5, 0) 
		ply:SetBodygroup(6, 0)
		ply:SetSkin(0)
	end
end)


Try using PlayerSetModel



TEAM_MARINE = DarkRP.createJob("Marine Leisure",{
color = Color(0, 255, 0, 255),
model = {"models/player/sanic/marinedp.mdl"},
description = [[You are a Marine]],
weapons = {"tfa_bf4_aek971","tfa_deagle","tfa_tec9"},
command = "marinel",
max = 0,
salary = 50,
admin = 0,
vote = false,
hasLicense = false,
category = "Marines",
PlayerSetModel = function(ply)
   ...
end


So far none of these have worked. I’m not sure why, since I’ve seen plenty of others with this problem and use these same fixes, to an extent, and it was fine for them.

Show what code you used

This is what I used off of my assumption as to what to put in place of “…”:

[LUA]
TEAM_MARINE = DarkRP.createJob(“Marine Leisure”,{
color = Color(0, 255, 0, 255),
model = {“models/player/sanic/marinedp.mdl”},
description = [[You are a Marine]],
weapons = {“tfa_bf4_aek971”,“tfa_deagle”,“tfa_tec9”},
command = “marinel”,
max = 0,
salary = 50,
admin = 0,
vote = false,
hasLicense = false,
category = “Marines”,
PlayerSetModel = function(ply)
ply:SetBodygroup(1, 3)
ply:SetBodygroup(2, 0)
ply:SetBodygroup(3, 3)
ply:SetBodygroup(4, 0)
ply:SetBodygroup(5, 0)
ply:SetBodygroup(6, 0)
ply:SetSkin(0)
end,
customCheck = function(ply) return CLIENT or ply:GetNWString(“usergroup”) == “marine” or ply:IsAdmin() end,
CustomCheckFailMsg = “You are not authorized to access this rank”
})
[/LUA]

It’s probably an issue with the model itself. Maybe those body groups don’t exist?

I mean, I’m not sure why they wouldn’t since they’re set up like that in the context menu.

This might be the problem, I don’t know but body groups start from 0 usually.