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: Remove Hats Script won't work?

Previous Thread :: Next Thread 
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
09 Jun 2014 04:25 AM
Hey There!
Im kinda new to Scripting, so this is probably a dumb question, but why doesnt this work???? It doesnt give any error, it just doesnt do anything. Its supposed to remove the Hat of the Random Player.

function randomPlayer()
local players = game.Players:GetPlayers()
return players[math.random(#players)]
end
local vanishing = randomPlayer()


if vanishing.Character:GetChildren().ClassName=="Hat" then
remove()
end

THX!
Planesoldier
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
09 Jun 2014 04:31 AM
Tried this:

if vanishing.Character:GetChildren()[i].ClassName=="Hat" then
vanishing.Character[i]:Remove()

Still wont work...
Report Abuse
magoo8 is not online. magoo8
Joined: 25 Apr 2009
Total Posts: 1122
09 Jun 2014 04:33 AM
Use a free model, study the script and see if you can make your own.
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
09 Jun 2014 04:38 AM
I tried, but it wont work....
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
09 Jun 2014 04:46 AM
Used this now:

for i=1, #vanishing.Character:GetChildren() do
if (vanishing.Character:GetChildren()[i].className == "Hat") then
vanishing.Character:GetChildren()[i]:remove()
end
end

But it removes 1 hat and then gives this error:

11:45:33.048 - ServerScriptService.Main Script:124: attempt to index field '?' (a nil value)
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
09 Jun 2014 04:50 AM
Nevermind, i fixed it :D
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