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.
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!