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

How do I locate a different TextButton that is in a gui?

Asked by 4 years ago

I have a Local Script that is inside "HowToPlay" to which when you click that button it sends "Play", "HowToPlay", and so on that is on the list away. But it doesn't.

script.Parent.MouseButton1Click:connect(function()
script.Parent.Play:TweenPosition(UDim2.new(5, 0,0.447, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.HowToPlay:TweenPosition(UDim2.new(5, 0,0.56, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Credit:TweenPosition(UDim2.new(5, 0,0.676, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Credit2:TweenPosition(UDim2.new(5, 0,0.771, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.HowToPlays:TweenPosition(UDim2.new(0.204, 0,0.179, 0), "InOut", "Quad", 1.5)
end)

Error: Play is not a valid member of TextButton

Picture: https://cdn.discordapp.com/attachments/165226280118255616/700114575718350918/sciprintg.PNG

2 answers

Log in to vote
0
Answered by 4 years ago

I believe you are just referencing the gui incorrectly, and forgot to add an extra .Parent to each line, so it would look like this:

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Play:TweenPosition(UDim2.new(5, 0,0.447, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Parent.HowToPlay:TweenPosition(UDim2.new(5, 0,0.56, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Parent.Credit:TweenPosition(UDim2.new(5, 0,0.676, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Parent.Credit2:TweenPosition(UDim2.new(5, 0,0.771, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Parent.HowToPlays:TweenPosition(UDim2.new(0.204, 0,0.179, 0), "InOut", "Quad", 1.5)
end)
Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Assuming that the GUIObjects share the same parent, the problem is you are looking for the other objects inside the GUIObjects. Change .Parent to .Parent.Parent

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Play:TweenPosition(UDim2.new(5, 0,0.447, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Parent.HowToPlay:TweenPosition(UDim2.new(5, 0,0.56, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent..Parent.Credit:TweenPosition(UDim2.new(5, 0,0.676, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Parent.Credit2:TweenPosition(UDim2.new(5, 0,0.771, 0), "InOut", "Quad", 1.5)
wait(.3)
script.Parent.Parent.HowToPlays:TweenPosition(UDim2.new(0.204, 0,0.179, 0), "InOut", "Quad", 1.5)
end)


Alternatively, you could just move the script into (I assume) the StarterGui, or whatever the parent of HowToPlay is.

0
The script for "HowToPlay" is inside of it, to where If i use .Parent.Parent. It's going to give me a "Play is not a valid member or Local Script" TheBuliderMC 84 — 4y
0
Nevermind. I noticed what I did wrong. wish I can accept both answers. (also you made a small error in line 4 ".Parent..Parent" TheBuliderMC 84 — 4y
0
Oops TiredMelon 405 — 4y
0
He literally wrote the same answer as me.. TiredMelon 405 — 4y

Answer this question