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

How do you Force a Player to Wear an Outift?

I tried many things but I cant seem to find out how. The script I was using didnt even work. I need it for a group. I would also like to know if it could be added to a certain group or team.

1 answer

✓ Accepted answer

To do it for a Group you could do Player:IsInGroup(ID). Example:

game.Players.PlayerAdded:connect(function(Player) -- Once a player is added
	if Player:IsInGroup(372) then -- Check if their in the group
		-- code here
	end -- End the if statement
end) -- End the PlayerAdded function

To do it for a Team you could check their TeamColor by Player.TeamColor. Example:

game.Players.PlayerAdded:connect(function(Player) -- Once a player is added
	Player.CharacterAdded:connect(function() -- Once a Character is added to the Player
		if Player.TeamColor == game:GetService("Teams")["Scripting Helpers"] then -- Check their team
			-- code here
		end -- End the if statement
	end) -- End the CharacterAdded function
end) -- End the PlayerAdded function

And for both of those, you could create a new Shirt and Pants on the Player's Character, though you might want to delete their old one first.

To delete their old one:

game.Players.PlayerAdded:connect(function(Player) -- Once a player is added
	Player.CharacterAdded:connect(function() -- Once a Character is added to the Player
		if Player.TeamColor == game:GetService("Teams")["Scripting Helpers"] then -- Check their team
			wait(1) -- Give it a chance to load, now thinking about it ChildAdded might've been better
			for _,v in pairs(Player.Character:GetChildren()) do -- Gather everything in their Character
				if v:IsA("Shirt") or v:IsA("Pants") then -- Check if its a shirt or pants
					v:Destroy() -- If it is, destroy it
				end -- End the if statement
			end -- End the for _,v in pairs statement
		end -- End the if statement
	end) -- End the CharacterAdded function
end) -- End the PlayerAdded function

To create new one(used random shirt and pants cause Scripting Helpers doesn't have any):

local Shirt = Instance.new("Shirt",Player.Character) -- Create new shirt
local Pants = Instance.new("Pants",Player.Character) -- Create new pants
Shirt.ShirtTemplate = "rbxassetid://363587040"
Pants.PantsTemplate = "rbxassetid://363587589"

It's important to note that for the ShirtTemplate and PantsTemplate, you'll have to remove 1 or 2 from the ID(363587042 to 363587040, and (363587591 to 363587589), .

Sorry I can't really explain it any better.

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