|
| 23 May 2017 10:51 PM |
It is suppose to remove the player's accessories when joined it DOES print the char.Name
function onPlayerEntered(newPlayer) game.Workspace:WaitForChild(newPlayer.Name) local char = game.Workspace:FindFirstChild(newPlayer.Name) if char then print(char.Name) wait(0.1) local w = char:GetChildren() for i = 1, #w do local c = w[i]:GetChildren() for i=1, #c do if (c[i].className == "Accessory") then c[i]:remove() end end end end end
game.Players.PlayerAdded:connect(onPlayerEntered)
|
|
|
| Report Abuse |
|
|
LinkMe
|
  |
| Joined: 30 Apr 2009 |
| Total Posts: 512 |
|
|
| 23 May 2017 10:56 PM |
| Try using the RemoveAccessories function. |
|
|
| Report Abuse |
|
|
| |
|
LinkMe
|
  |
| Joined: 30 Apr 2009 |
| Total Posts: 512 |
|
|
| 23 May 2017 10:58 PM |
| wiki.roblox.com/index.php?title=API:Class/Humanoid/RemoveAccessories |
|
|
| Report Abuse |
|
|
|
| 23 May 2017 11:10 PM |
@LinkMe
So I would do
character.Humanoid:RemoveAccessories()
|
|
|
| Report Abuse |
|
|
Jake_Kinq
|
  |
| Joined: 23 May 2015 |
| Total Posts: 72 |
|
|
| 23 May 2017 11:11 PM |
| it looks valid,but do what that other guy said. |
|
|
| Report Abuse |
|
|
| |
|
wjg999
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 95 |
|
|
| 24 May 2017 02:13 AM |
| might want to change the second i to a j or something else since it is adding to i in both loops , meaning that if it ends the inner loop it would suddenly be in the outer loop with an i of of a number other than 1 thus it skips a lot. |
|
|
| Report Abuse |
|
|
wjg999
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 95 |
|
|
| 24 May 2017 02:21 AM |
| 2nd thing, :remove() shifts the table so in the second loop will skip over parts if it does not subtract 1 from the second i inside the if statement since if c[1] was removed c[2] is now in c[1] its spot |
|
|
| Report Abuse |
|
|
wjg999
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 95 |
|
|
| 24 May 2017 02:41 AM |
| scrap that last bit, thought it was removing stuff from the table, not just the item |
|
|
| Report Abuse |
|
|