Trying to make GUI move when a button is pressed but it isn't working

I want to make it so when a button is pressed GUI goes up from the bottom of the screen to around the middle and when the button is pressed again the GUI goes back down.
If I make it so that the script waits 10 seconds and then moves the GUI it works however if I link it up to the button being pressed it doesn’t work. The button can be pressed because I have other scripts that work when it’s pressed. The script is a Local Script but even with it being a normal script it doesn’t seem to work.
I have looked on the Developer Forum and I tried their scripts but it doesn’t work. I feel the solution is simple and I’m just missing something minor. The script is under the button.
This is the script I’m using:

local Gui = game.StarterGui.RebirthGui.Frame
local Toggle = script.Parent
local on = false

Toggle.MouseButton1Click:Connect(function()
	if on == false then
		Gui:TweenPosition(
			UDim2.new(0.5, 0, 0.5, 0),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Sine,
			0.5
		)
		on = true
	elseif on == true then
		Gui:TweenPosition(
			UDim2.new(0.5, 0, 1.5, 0),
			Enum.EasingDirection.In,
			Enum.EasingStyle.Sine,
			0.5
		)
		on = false
	end
end)
2 Likes

I see the Problem.

  1. This should be in a local script
  2. You are moving the wrong thing. Currently you are moving the frame from the storage/server with local Gui = game.StarterGui.RebirthGui.Frame. Instead you should move the players UI, so basically:
local Gui = game:GetService("Players").LocalPlayer.PlayerGui.RebirthGui.Frame

And this should be working then, since now the path is directed to the PlayerGui.

3 Likes

I tried it with a different button and it worked. Now I just have to try and get it to work with the button I want it to. The button works when under the same ScreenGui but not when under a frame. Still testing.
I got the button to work. For whatever reason it didn’t work unless it was under the same ScreenGui and under nothing else.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.