generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Why can't I remove shirt or pants?

Previous Thread :: Next Thread 
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
11 May 2014 01:15 PM
I'm trying to do this

Game.Players.PlayerAdded:connect(function(Player)

Player.CharacterAdded:connect(function(Character)

for i,v in pairs(Character:GetChildren()) do
if v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") then
v:Destroy()
end
end

end)
end)

--
But alas, it won't remove hats, shirts, or pants? why?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
11 May 2014 01:16 PM
They havent loaded, use :WaitForChild() before removing.
Report Abuse
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
11 May 2014 01:18 PM
But which child do I wait for? It's not guaranteed that said character will even have any of these things?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
11 May 2014 01:20 PM
Try to find a way..?
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
11 May 2014 01:22 PM
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)

p:WaitForDataReady()

for m, c in pairs(c:children()) do
if c.className == "Hat" or c.className == "Shirt" or c.className == "Pants" then
c:remove()
end
end

end)
end)
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
11 May 2014 01:24 PM
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
player.CharacterAdded:connect(function(char)
for _, v in pairs(char:GetChildren()) do
if v.ClassName == "Shirt" or v.ClassName == "ShirtGraphic" or v.ClassName == "Hat" or v.ClassName == "Pants" then
v:Destroy()
end
end
end)
end)
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
11 May 2014 01:25 PM
^

Not really sure but if you use :WaitForDataReady() and then add a characteradded event, won't it fail?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
11 May 2014 01:26 PM
Oh, put it in the wrong spot, use Jimmy's
Report Abuse
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
11 May 2014 01:27 PM
Oh hmm, I got it by adding in a ChildAdded event, but that looks more efficient
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
11 May 2014 01:28 PM
Game.Players.PlayerAdded:connect(function(Player)

Player.CharacterAdded:connect(function(Character)
wait(2)--ive found sometimes I got to add a wait of some kind
for i,v in pairs(Character:GetChildren()) do
if v:IsA("Hat") or v:IsA("Shirt") or v:IsA("Pants") then
v:Destroy()
end
end

end)
end)
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
11 May 2014 01:29 PM
@Island, some people have really slow computers and a wait(2) wont be enough. :WaitForDataReady() waits until theyve completely loaded.
Report Abuse
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
11 May 2014 01:29 PM
ehh the wait could vary though. and I want it to be instant. I've got what I need working though so thanks everyone.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
11 May 2014 01:30 PM
WaitForDataReady() waits until they can load/save data
meh,idk
Report Abuse
brinkokevin is not online. brinkokevin
Joined: 25 Jul 2012
Total Posts: 1673
11 May 2014 01:32 PM
Game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character.ChildAdded:connect(function(c)
if c:IsA("Hat")or c:IsA("Shirt")or c:IsA("Pants")then
c:Destroy()
end
end)
end)
end)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
11 May 2014 01:33 PM
Game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character.ChildAdded:connect(function(c)
if c:IsA("Clothing")then
c:Destroy()
end
end)
end)
end)

bam
Report Abuse
AetherShotgun is not online. AetherShotgun
Joined: 17 Mar 2014
Total Posts: 656
11 May 2014 01:48 PM
How about I show you how it's done :)?

game.Players.PlayerAdded:connect(function(Player)
Player.CanLoadCharacterAppearance = false
end)

Now they are a classic noob model without any customization.
Report Abuse
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
11 May 2014 03:42 PM
Oh that's handy Aether, though I want to keep custom faces or T-Shirts(for now)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image