Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

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.

4 comments

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"

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"

0

Oops

0

He literally wrote the same answer as me..

This discussion is preserved as it was. New answers, comments, and votes are closed.