NeonKitty
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 87 |
|
|
| 01 Aug 2013 09:52 PM |
| I made a gui that if you select the color, then the torso color becomes the buttons background color. The problem is that i need to put a script in each individual button to do this. Is there a way i can make it just one script so that the player's torso color = the background color of the gui button clicked? |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2013 10:05 PM |
Make this script be a child of the label/frame where all the buttons are located.
for i,v in pairs (script.Parent:GetChildren()) do if v:IsA("TextButton") then v.MouseButton1Click:connect(function(player) --I believe that player is what this documents, but it might be mouse. player.Character.Torso.Color = v.BackgroundColor --Might need to fix caps. end end
--I think this will work, but I'm not completely sure. Let me know what happens XD
*Tell me about the rabbits, George* |
|
|
| Report Abuse |
|
|
NeonKitty
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 87 |
|
|
| 01 Aug 2013 10:16 PM |
The last end is underlined in red and says ") expected (to close '(' at line 3 near 'end'"
what does that mean? |
|
|
| Report Abuse |
|
|
NeonKitty
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 87 |
|
|
| 01 Aug 2013 10:26 PM |
| Oh wait... how would I do it if all the text buttons are in frames.. is there a way to get the child of a child??? |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2013 10:36 PM |
Second end should look like: end)
"is there a way to get the child of a child???" parent.child.child--? |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2013 10:39 PM |
Heres how:
for _,v in pairs(script.Parent:GetChildren()) do if v:IsA("Frame") then for _,x in pairs(v:GetChildren()) do if x:IsA("TextButton") then x.MouseButton1Down:connect(function () game.Players.LocalPlayer.Character:WaitForChild("Torso").BrickColor = BrickColor.new(x.BackgroundColor3) end) end end end end
(Note, this should be used in a LocalScript |
|
|
| Report Abuse |
|
|
NeonKitty
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 87 |
|
|
| 01 Aug 2013 10:43 PM |
| There are a bunch of frames each with a text button. I want to manipulate all the text buttons so that if you click it, then something can change color to the text button's background color. |
|
|
| Report Abuse |
|
|
NeonKitty
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 87 |
|
| |
|
|
| 01 Aug 2013 10:45 PM |
That's exactly what my script does.
Lets say the parent of each of the frames you are trying to get is parented to a screenGui
My script locates each frames and adds a torso color change event to each textbutton it finds within those frames. |
|
|
| Report Abuse |
|
|
NeonKitty
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 87 |
|
|
| 01 Aug 2013 10:52 PM |
| OMG THANK YOU SO MUCH CLONE NOW I CAN REDUCE LAG YAAAAAY!!! |
|
|
| Report Abuse |
|
|