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: Invisible hats

Previous Thread :: Next Thread 
abaw7 is not online. abaw7
Joined: 23 Oct 2009
Total Posts: 745
22 Jul 2012 01:16 AM
Ok so now when i sit in a seat that has this script (1) in it, My hats won't disapear it is probably just a simple mistake but i'm tired and haven't been able to figure it out.

(1):

function scan(p)
local parts = {}
for _,v in pairs(p:GetChildren()) do
if (v:IsA("BasePart")) then
table.insert(parts,v)
end
if (v.ClassName == "Hat") then -- Fixing a bug
scan(v)
end
scan(v)
end
return parts
end

script.Parent.ChildAdded:connect(function(obj)
if ((not obj:IsA("Weld")) or (obj.Name ~= "SeatWeld")) then return end
local p = game.Players:GetPlayerFromCharacter(obj.Part1.Parent)
for i,v in pairs(scan(p.Character)) do
v.Transparency = 1
end
end)

script.Parent.DescendantRemoving:connect(function(obj)
if ((not obj:IsA("Weld")) or (obj.Name ~= "SeatWeld")) then return end
local p = game.Players:GetPlayerFromCharacter(obj.Part1.Parent)
for i,v in pairs(scan(p.Character)) do
v.Transparency = 0
end
end)
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
22 Jul 2012 01:18 AM
Check if it's a Hat then do hat.Handle.Transparency=1
Report Abuse
abaw7 is not online. abaw7
Joined: 23 Oct 2009
Total Posts: 745
22 Jul 2012 01:21 AM
"Handle" Is a Basepart. The Scan function scans the character when they enter put the base parts into a table and returns the table. Then the added methods use this table to change the transparency. It works for all the parts in the character, But hats. I'm trying to figure out how to make it work for hats as well.
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
22 Jul 2012 01:24 AM
Honestly, the way You're doing this is alittle over-complicated.
Report Abuse
abaw7 is not online. abaw7
Joined: 23 Oct 2009
Total Posts: 745
22 Jul 2012 01:27 AM
It needs to account for all hats possible and if you feel like indexing all the hats in roblox be my guest but this way is actually easier.
Report Abuse
abaw7 is not online. abaw7
Joined: 23 Oct 2009
Total Posts: 745
22 Jul 2012 05:21 PM
Bump
Report Abuse
abaw7 is not online. abaw7
Joined: 23 Oct 2009
Total Posts: 745
22 Jul 2012 05:51 PM
Bump'dy bump bump
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