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

how can i add a "Accessory remover" inside this script ?

hello , i want add a accessory remover inside this script at line 20 but i don't know how to do this can you help me please ? thanks you !

script (line 20)

local function ChangeClothes(char, shirtid, pantsid)
    local shirt = char:FindFirstChildOfClass"Shirt" or Instance.new("Shirt", char)
    local pants = char:FindFirstChildOfClass"Pants" or Instance.new("Pants", char)
    shirt.ShirtTemplate = shirtid
    pants.PantsTemplate = pantsid
end

local remote = game.ReplicatedStorage.Security
				LVL5 = game.ReplicatedStorage["[SCP] Card-L5"]
						Flashlight = game.ReplicatedStorage.Flashlight
						P90 = game.ReplicatedStorage["P90 TR"]
						

function remote.OnServerInvoke(player, TeamName)
	if #game:GetService("Teams"):FindFirstChild("Security Departement Head"):GetPlayers() == 0 then -- team check
    player.TeamColor = BrickColor.new("Really blue") -- Team Change

			player:LoadCharacter()
			if  game.Workspace[player.Name].ClassName == ("Accessory") then
-- I WANT ADD ACCESSORY REMOVER HERE
			end
			       local char = player.Character or player.CharacterAdded:Wait()
        ChangeClothes(char, "rbxassetid://129732937", "rbxassetid://175974404") --replace with your desired ids			
		LVL5:Clone().Parent = game.Players[player.Name].Backpack
		Flashlight:Clone().Parent = game.Players[player.Name].Backpack
		P90:clone().Parent = game.Players[player.Name].Backpack
		
			
		else
		print ("Team SECU is full") -- team is currently full
	end
	end

1 comment

1 answer

✓ Accepted answer

Loop throughout the player's character, checking whether or not the player holds an accessory, then delete the object. We can usually accomplish this task by using and understanding a for i,v in pairs loop(You can find this here: http://wiki.roblox.com/index.php/Loops). Next, we would have to determine whether the object in the player's character is an accessory. We can accomplish by using :IsA instance given to us by ROBLOX (Which can be found here: http://wiki.roblox.com/index.php?title=API:Class/Instance/IsA[](http://)). Understanding these two concepts can now lead us to form the coding part of it. Use this as an example.

for i,v in pairs(char:GetChildren()) do -- Looping through the player's character
if v:IsA("Accessory") -- Determining whether or not it's an accessory
v:Destroy() -- Destroying it
end
end

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