|
| 24 Aug 2013 02:43 PM |
Make the player's hat(s) invisible by clicking a button in a gui? Here is my script: pcharacter = script.Parent.Parent.Parent.Parent.Character
button.MouseButton1Click:connect(function() d = pcharacter.Parent:GetChildren() for i = 1,#d do if (d[i].className == "Hat") then d[i].Handle.Transparency = 1 end end end)
~DevilDefeater - Popped your bubble~ |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2013 02:45 PM |
| The handle is already transparent. You need to get rid of the mesh. |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 24 Aug 2013 02:45 PM |
Uh, yeah, that looks pretty clean to me. If you want to shorten it:
button.MouseButton1Click:connect(function() for i,v in pairs(pcharacter:GetChildren()) do if v:IsA("Hat") then v.Handle.Transparency = 1 end end end) |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 24 Aug 2013 02:46 PM |
Also, a mesh cannot be seen if it's parent brick is transparent
So... The handle isn't transparent |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2013 02:47 PM |
Oh... Please, fix my script. I want it to make the hats invisible and when clicked again, it goes back :\
value = 0 pcharacter = script.Parent.Parent.Parent.Parent.Character button = script.Parent frame = script.Parent.Parent.LeaderboardFrame la = pcharacter["Left Arm"] ra = pcharacter["Right Arm"] ll = pcharacter["Left Leg"] rl = pcharacter["Right Leg"] hd = pcharacter["Head"] ts = pcharacter["Torso"]
button.MouseButton1Click:connect(function() if value == 0 then d = pcharacter.Parent:GetChildren() for i = 1,#d do if (d[i].className == "Hat") then d[i].Handle.Transparency = 1 end end la.Anchored = true ra.Anchored = true ll.Anchored = true rl.Anchored = true hd.Anchored = true ts.Anchored = true la.Transparency = 1 ra.Transparency = 1 ll.Transparency = 1 rl.Transparency = 1 hd.Transparency = 1 ts.Transparency = 1 pcharacter.Humanoid.WalkSpeed = 0 frame.Visible = true button.Text = "Close Stats" value = 1 elseif value == 1 then d = pcharacter.Parent:GetChildren() for i = 1,#d do if (d[i].className == "Hat") then d[i].Handle.Transparency = 0 end end la.Anchored = false ra.Anchored = false ll.Anchored = false rl.Anchored = false hd.Anchored = false ts.Anchored = false la.Transparency = 0 ra.Transparency = 0 ll.Transparency = 0 rl.Transparency = 0 hd.Transparency = 0 ts.Transparency = 0 pcharacter.Humanoid.WalkSpeed = 16 frame.Visible = false button.Text = "Open Stats" value = 0 end end)
Do I need to save the last mesh (Like a clone?), and put it back when clicked?
~DevilDefeater - Popped your bubble~ |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 24 Aug 2013 02:51 PM |
local active = false pcharacter = script.Parent.Parent.Parent.Parent.Character button = script.Parent frame = script.Parent.Parent.LeaderboardFrame la = pcharacter["Left Arm"] ra = pcharacter["Right Arm"] ll = pcharacter["Left Leg"] rl = pcharacter["Right Leg"] hd = pcharacter["Head"] ts = pcharacter["Torso"]
button.MouseButton1Click:connect(function() if not active then active = trueif value == 0 then for i,v in pairs(pcharacter:GetChildren()) do if v:IsA("Hat') then v.Handle.Transparency = 1 elseif v:IsA("Part") then v.Anchored = true v.Transparency = 1 end end pcharacter.Humanoid.WalkSpeed = 0 frame.Visible = true button.Text = "Close Stats" elseif active then active = false for i,v in pairs(pcharacter:GetChildren()) do if v:IsA("Hat') then v.Handle.Transparency = 1 elseif v:IsA("Part") then v.Anchored = false v.Transparency = 0 end end pcharacter.Humanoid.WalkSpeed = 16 frame.Visible = false button.Text = "Open Stats" end end) |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2013 02:52 PM |
@Geomaster Thank you, I will try it :)
~DevilDefeater - Popped your bubble~ |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2013 02:53 PM |
@Geomaster Could you please fix this line: if not active then active = trueif value == 0 then
~DevilDefeater - Popped your bubble~ |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 24 Aug 2013 02:54 PM |
WHOOPS, forgot to erase that
Here we go
local active = false pcharacter = script.Parent.Parent.Parent.Parent.Character button = script.Parent frame = script.Parent.Parent.LeaderboardFrame -- Didn't need that other stuff
button.MouseButton1Click:connect(function() if not active then active = true for i,v in pairs(pcharacter:GetChildren()) do if v:IsA("Hat') then v.Handle.Transparency = 1 elseif v:IsA("Part") then v.Anchored = true v.Transparency = 1 end end pcharacter.Humanoid.WalkSpeed = 0 frame.Visible = true button.Text = "Close Stats" elseif active then active = false for i,v in pairs(pcharacter:GetChildren()) do if v:IsA("Hat') then v.Handle.Transparency = 1 elseif v:IsA("Part") then v.Anchored = false v.Transparency = 0 end end pcharacter.Humanoid.WalkSpeed = 16 frame.Visible = false button.Text = "Open Stats" end end) |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2013 02:56 PM |
@Geomaster Next time, please put "Hat" instead of "Hat' :\ By the way, thank you, I will tell you if there are errors :)
~DevilDefeater - Popped your bubble~ |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 24 Aug 2013 02:58 PM |
| Shift keys are never reliable |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2013 03:01 PM |
@Geomaster Thank you, it worked, but the hat meshes doesn't come back :\
~DevilDefeater - Popped your bubble~ |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 24 Aug 2013 03:04 PM |
Oh, my bad
There's two lines that say:
if v:IsA("Hat') then v.Handle.Transparency = 1
Change the second one to 0 |
|
|
| Report Abuse |
|
|