of     1   

chandrakantswarnkar
#220280730Sunday, July 02, 2017 11:54 AM GMT

Plz help me making a script that removes any accessory attached to a player when a player joins the game.
chandrakantswarnkar
#220281061Sunday, July 02, 2017 12:05 PM GMT

anyone?! :(
HlKMAT
#220281210Sunday, July 02, 2017 12:10 PM GMT

local function dropHats() local localPlayer = game:GetService("Players").LocalPlayer if localPlayer and localPlayer.Character then for _, obj in pairs(localPlayer.Character:GetChildren()) do if obj:IsA("Accoutrement") then obj.Parent = game.Workspace end end end end game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if not gameProcessedEvent then if inputObject.KeyCode == Enum.KeyCode.Equals then dropHats() end end end)
HlKMAT
#220281260Sunday, July 02, 2017 12:11 PM GMT

LocalScript in the PlayerScripts
chandrakantswarnkar
#220281511Sunday, July 02, 2017 12:17 PM GMT

It works when I press the equal button and I wanted them to be destroyed so I did obj:Destroy() but I also want them to be destroyed when a player is added not when any key is pressed.. anyway Thanks a lot :)
chandrakantswarnkar
#220286491Sunday, July 02, 2017 2:19 PM GMT

*beep* Help
HlKMAT
#220291820Sunday, July 02, 2017 4:08 PM GMT

game.Players.PlayedAdded:connect(function(player) if player and player.Character then for _, obj in pairs(player.Character:GetChildren()) do if obj:IsA("Accoutrement") then obj.Parent = game.Workspace end end end end)
HlKMAT
#220291876Sunday, July 02, 2017 4:09 PM GMT

game.Players.PlayedAdded:connect(function(player) if player and player.Character then for _, obj in pairs(player.Character:GetChildren()) do if obj:IsA("Accoutrement") then obj:Destroy() end end end end) ignore the script above, this is right
chandrakantswarnkar
#220292151Sunday, July 02, 2017 4:14 PM GMT

I tried same earlier but it isn't working T-T I made a new script in server script service and wrote it/pasted but that twitter bird and other accessories were still there.
CelluloidCats
#220292760Sunday, July 02, 2017 4:23 PM GMT

There's a function for this in the api under Player or Players look for it
chandrakantswarnkar
#227482036Sunday, November 12, 2017 5:09 PM GMT

Couldn't find it! RE BUMP! Help! On character added -- destroy char:children doesnt work as well
chandrakantswarnkar
#227511411Monday, November 13, 2017 5:16 AM GMT

...
doggy00
#227512251Monday, November 13, 2017 5:59 AM GMT

game.Players.PlayerAdded:connect(function(pureya) pureya.CharacterAdded:connect(function(kyarakuta) repeat wait() until pureya:HasAppearanceLoaded() for i,v in pairs(kyarakuta:GetChildren()) do if v:IsA("Accoutrement") then v:Destroy() end end end) repeat wait() until pureya:HasAppearanceLoaded() for i,v in pairs(pureya.Character:GetChildren()) do if v:IsA("Accoutrement") then v:Destroy() end end end)
doggy00
#227512311Monday, November 13, 2017 6:02 AM GMT

Forgot to mention: you should put that in a server script in Workspace or ServerScriptService, but ServerScriptService is highly recommended over Workspace.
Voxxie
#227512501Monday, November 13, 2017 6:13 AM GMT

doggy00
#227527675Monday, November 13, 2017 8:47 PM GMT

Voxxie's way works just as well. It's pretty much the exact same thing except simplified into a single built-in function. I wasn't aware that function existed, but either way will work. :RemoveAccessories() is most likely better to use since it saves time as far as coding goes, but both of them are around the same speed (around 0.0025 on average), so I guess it's just personal preference.

    of     1