Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Say I want all the players accessories off them when they first join, how would I go about that?

Asked by 4 years ago

I haven't scripted for about 7 months so im not sure if this would be good at all

I'm pretty sure its along the lines of

1Players = game.Players
2Players.CharacterAdded:Connect function()
3Player.Character.Hair:Remove()
4etc
5etc
6end

I was hoping to atleast find a tutorial on youtube or something but I mean I could always just rip an accessory/face remover from the workshop and put it where the player spawns, that could actually work why dont I just do that? genius

im gonna post this anyway for advice but im still trying that epiphany I thought of just now

okay bye

2 answers

Log in to vote
3
Answered by 4 years ago

You can use a for loop to iterate through the Character's children, and delete their accessories like so;

1game.Players.PlayerAdded:Connect(function(player)
2    local char = player.Character
3    for _,v in pairs(char:GetChildren()) do
4        if v:IsA("Accesory") then
5            v:Destroy()
6        end
7    end
8end)
0
do I put this in a localscript or a server script and in which folder? THEGOBLINTOPLAD 0 — 4y
0
Server Script, put it anywhere that Server Scripts can run. zboi082007 270 — 4y
0
as a side note to this great answer, you can replace the for loop with simply: `Character.Humanoid:RemoveAccessories()` User#23252 26 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Kind of like what zboi said, I'd do something like this:

1game.Players.PlayerAdded:Connect(function(Plr)
2Plr.CharacterAdded:Connect(function(Char)
3Plr.CharacterAppearanceLoaded:Wait()
4Char.Humanoid:RemoveAccessories()
5end)
6end)
0
Also it'd go in a ServerScript. ToastyWarmBread 54 — 4y

Answer this question