Forcing players to the default package

Hello developers! I’m making a laser tag fps game, and use morphs to give players armor. To make this
armor fit properly, the players need to be wearing the default (block) package, and no front or back accesories.
If I try to achieve this in game settings, I get an error code: Couldn’t save. For the front and back accesories there is not an option avalible at all.
Can you help me out?

1 Like

You can iterate through a character’s accessories to see if they have a "BodyBackAttachment" and "BodyFrontAttachment" attachment. (Used for back and front accessories)

Here’s a script I made for you, add a serverscript in StarterPlayer > StarterCharacterScripts:

local Character = script.Parent

for _, hat in pairs(Character:GetChildren()) do
	if hat:IsA("Accessory") then
		if hat:FindFirstChild("BodyBackAttachment", true) or hat:FindFirstChild("BodyFrontAttachment", true) then
			hat:Destroy()
			print("Destroyed " ..hat.Name)
		end
	end
end
2 Likes

Hello! Thanks for your reply, I tried to make the script work but it didn’t. Do you have a solution?

1 Like

Can you show me your hierachy and the script? It works well for me. Does it print any errors?

I can’t make screenshots for some reason but I have a script in startercharacterscripts with the exact code you supplied.

I wear a boombox on my avatar and it works well.

Do you get any errors in the console/output and what’s the outcome? Does it never destroy any back/front accessory?

It never destroys anything and it does not output any errors either.

Are you sure you have any front/back accessories equipped? (Mention that they must be sorted as front/back accessories in the avatar editor)

UXZ an easier way of doing that is using StarterCharacters this will save u alot of time and requires no knowledge of scripting unless u wanna go far with it.

I think he only wants the back and front accessories to be deleted from the character, not having a full preset character.

I have a backpack and a “i voted” button equipped on my avatar to test your script. It didn’t destroy it.
What type of script do you use? Can I see your workspace?

Yeah but I prefer still allowing some customisation for people.

My script deletes the accessories once the character is loaded, not sure what makes the outcome for you different. For me, it works well.

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
for _, hat in pairs(Character:GetDescendants()) do
	if hat:IsA("Accessory") then
		if hat:FindFirstChild("BodyBackAttachment") or hat:FindFirstChild("BodyFrontAttachment") then
			hat:Destroy()
		end
	end
end
end)
end)

If this doesn’t wok try adding a wait() before the loop.

1 Like

This also did not work for some reason…

Add a wait() before the for _, loop

1 Like

This made it work for some reason. Thanks.

And of course thanks @Winbloo for your script!

2 Likes