Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make it so when you enter in the game it gives you a uniform?

So when you enter the game it will change your shirt and pants only if you are in a group.

Script:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		
		if player:IsInGroup(5816087) then
			local Shirt = char.Shirt
			local Pants = char.Pants
			
			Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=3058874786"
			Pants.PantsTemplate = "http://www.roblox.com/asset/?id=3019791149"
		
		end
		
end)				
end)

This is the output: 14:17:49.556 - ServerScriptService.Uniforms.Uniforms:5: attempt to index nil with 'Character'

1 answer

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
	char:WaitForChild('Humanoid')
	char:WaitForChild('HumanoidRootPart')
	wait()
        if player:IsInGroup(5816087) then
            local Shirt, Pants
            if char:FindFirstChild('Shirt') then
	         Shirt = char.Shirt
	    else
	         Shirt  = Instance.new('Shirt', char)
            end
            if char:FindFirstChild('Pants') then
	         Pants = char.Shirt
	    else
	         Pants = Instance.new('Pants', char)
            end	
            Shirt.ShirtTemplate = "rbxassetid://3058874786"
            Pants.PantsTemplate = "rbxassetid://3019791149"

        end

end)                
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.