I have a script, I am about to clone it into all the other buttons.
But i have an idea, I want to put the script in the frame, and do the code for all of the buttons in one script.
01 | while true do |
02 | wait() |
03 | script.Parent.EffectLabel.Text = script.Parent.Text |
04 |
05 | script.Parent.NameLabel.Text = script.Parent.nameValue.Value |
06 | script.Parent.NameLabel.EffectLabel.Text = script.Parent.nameValue.Value |
07 |
08 | script.Parent.CostLabel.Text = "[" ..script.Parent.costValue.Value.. " points]" |
09 | if script.Parent.costValue.Value = = 0 then |
10 | script.Parent.CostLabel.Text = "[free]" |
11 | end |
12 | script.Parent.CostLabel.EffectLabel.Text = script.Parent.CostLabel.Text |
13 |
14 | if game.Players.LocalPlayer.leaderstats.Points.Value > = script.Parent.costValue.Value then |
15 | script.Parent.CostLabel.TextColor 3 = Color 3. new( 1 , 1 , 127 / 255 ) --has enough to purchase |
16 | else |
17 | script.Parent.CostLabel.TextColor 3 = Color 3. new( 1 , 100 / 255 , 100 / 255 ) --does not have enough to purchase |
18 | end |
19 |
20 | end |
Is there any way I can do this script, in all the buttons in the frame? In one script
01 | while true do |
02 | wait() |
03 | for i,v in pairs (script.Parent:GetChildren()) do |
04 | if v.ClassName = = "Text Button" then |
05 | v.EffectLabel.Text = script.Parent.Text |
06 |
07 | v.NameLabel.Text = v.nameValue.Value |
08 | v.NameLabel.EffectLabel.Text = v.nameValue.Value |
09 |
10 | v.CostLabel.Text = "[" ..v.costValue.Value.. " points]" |
11 | if v.costValue.Value = = 0 then |
12 | v.CostLabel.Text = "[free]" |
13 | end |
14 | v.CostLabel.EffectLabel.Text = v.CostLabel.Text |
15 |
Basically what
1 | for i,v in pairs (script.Parent:GetChildren()) do |
2 | end |
does is it classifies everything inside of script.Parent as V so you can make changes to everything at once.
1 | if v.ClassName = = "Text Button" then |
Makes it so that it only changes text buttons (I'm assuming that's what you're using as buttons, if not change that classname to whatever it is, otherwise it won't work) without that, if you have anything in the Frame besides what you want the script to edit (even the script itself) then the script will break.
If it doesn't work, comment and tell me if there are any errors in the output. I'll try to fix it.