Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[STILLNEEDHELP]GUI Text Button click, makes stuff visible and changes text?

Asked by 9 years ago

I have made a script that has the purpose of making the invisible text buttons on the desc panel visible, then changing the text on those newly visible to the name of the car on the name text button, and on the buy text button putting the price. The picture of it is here http://prntscr.com/6bx9ln. I don't know whats wrong?

script.Parent.MouseButton1Click:connect(function()
 local x = StarterGui.Carshop.Frame  --the variable
 x.Name.Visible = true --making the text button "name" visible
 x.Buy.Visible = true --making the text button "buy" visible
 x.Buy.Text = "$5000" --Changing the text from "buy" to $5000
 x.Name.Text = "Civi Car" --Changing the text from "Name" to Civi Car"
 end)

PS: If I don't mark your answer as correct right away its probably because I am testing it out in studio to see if it works, please don't think I am some sort of troll.

0
Do you see any errors in the output? Minifig77 190 — 9y
0
Yes, in the output is says 16:20:28.584 - Players.Player.PlayerGui.Carshop.Frame.Civi Car.Script:2: attempt to index global 'StarterGui' (a nil value) 16:20:28.585 - Stack Begin 16:20:28.585 - Script 'Players.Player.PlayerGui.Carshop.Frame.Civi Car.Script', Line 2 16:20:28.586 - Stack End DeciusGalerius 20 — 9y
0
I edited my answer! BSIncorporated 640 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

The reason this doesn't work is because you have it accessing StarterGui, which doesn't involve the current player. Instead change it to

script.Parent.MouseButton1Click:connect(function()
 local x = script.Parent.Carshop.Frame --Make sure that your # of Parents is correct
 x.Name.Visible = true
 x.Buy.Visible = true
 x.Buy.Text = "$5000"
 x.Name.Text = "Civi Car"
 end)

Now that I can see your tree, I will show what it should look like now:

script.Parent.MouseButton1Click:connect(function()
 local x = script.Parent.Parent --since the second parent of your script is the frame you want to access there is no need to do more than script.Parent.Parent
 x.Name.Visible = true
 x.Buy.Visible = true
 x.Buy.Text = "$5000"
 x.Name.Text = "Civi Car"
 end)

I assume that you're going to want this script for all of your cars so Instead of having to retype all of the names for

x.Name.Text

you can do this:

x.Name.Text - ""..script.Parent.Name

with this, your "Name.Text" will always change to the script's parent's name. Hope this helped!

0
Not working, the output says Carshop is not valid member of frame, I tried a bunch of stuff also. Here is a picture of where the script is, hope it helps http://prntscr.com/6byc60 Thanks. DeciusGalerius 20 — 9y
0
Hmm, in output it is saying "Players.Player.PlayerGui.Carshop.Frame.Civi Car.Script:3: attempt to index field 'Name' (a string value)". Maybe I should change the text button from name to something else. Is name a event or something, is that making it not work? I am only trying to enable visibility and changing text in that script. DeciusGalerius 20 — 9y
Ad

Answer this question