Textbutton/ GUI not working

hello, I’m trying to tween a GUI but it doesn’t seem like it would tween at all.
I am still a beginner at scripting so I might need someone to explain what went wrong with this part of the script. :frowning:

what I am doing here is that I want to make this “circle” GUI to tween to the right when the “play button” is clicked, but whenever I test it, it simply doesn’t work (nothing happens)

heres the script too if this is needed

local creditB = script.Parent.mainmenu.Credits
local settingsB = script.Parent.mainmenu.settingsbutton
local playB = script.Parent.mainmenu.playbutton


local CR = script.Parent.mainmenu.circle
local CH = script.Parent.mainmenu.characters

playB.MouseButton1Up:Connect(function(click)
	CR:TweenPosition(UDim2.new(0,-0.3,0,0))
end)

thank you!

1 Like

Any errors? If not, you might be trying to move the UI element to the position it’s already in.

1 Like

nope, there weren’t any errors in output.
ill try what you’ve said though, thank you

3 Likes

after a few testing ive finally found an error within output
something like "mainmenu is not a valid member of Frame "Players.Eeveeyaoyao123.PlayerGui.ScreenGui.mainmenu "

1 Like

I think it gives that error because the startergui loads ‘slowly’. So maybe try waiting for the char to be added or define the circle and characters when the function is triggered.

1 Like

i see, so should I be adding something like waitforchild or findfirstchild? ive looked through devforums but idk how they work :sweat_smile:

1 Like

Hmm, you could do game.Players.LocalPlayer:WaitForChild("PlayerGui") for example.

1 Like


like this? (tested with the updated script)

2 Likes

Yes like that, have you tried it?

1 Like

yup i did, didn’t work out though

Try using this code for your script:

local MainMenu = script.Parent:WaitForChild("mainmenu")
local creditB = MainMenu.Credits
local settingsB = MainMenu.settingsbutton
local playB = MainMenu.playbutton


local CR = MainMenu.circle
local CH =MainMenu.characters

playB.MouseButton1Up:Connect(function()
	CR:TweenPosition(UDim2.new(0,-0.3,0,0), "InOut", "Linear", 0.4, true)
end)
3 Likes

interesting, now a new message pops up and the tweening didn’t work either

1 Like

wait where is this script located? Is it directly located inside the ScreenGui or inside a frame or something?

image
i feel like i should put it back into screengui

1 Like

Found the problem! You were mentioning in the script that the mainmenu frame is inside the parent of the script, when in reality, the script is already inside the mainmenu frame.
Use this updated code for your script:

local MainMenu = script.Parent
local creditB = MainMenu:WaitForChild("Credits")
local settingsB = MainMenu:WaitForChild("settingsbutton")
local playB = MainMenu:WaitForChild("playbutton")


local CR = MainMenu:WaitForChild("circle")
local CH = MainMenu:WaitForChild("characters")

playB.MouseButton1Up:Connect(function()
	CR:TweenPosition(UDim2.new(0,-0.3,0,0), "InOut", "Linear", 0.4, true)
end)
1 Like

thank you for helping so much : )
but I feel like im missing a step or something because similar errors keep popping up


sorry again ^^;

2 Likes

i miss spelled WaitForChild. I just edited the code above. Recopy and paste the code into your script

omg thank you! the code worked : D!!!

2 Likes

You are welcome! Happy to help!

1 Like