Problem with tween position of GUI(idk why)

  1. What do you want to achieve? Keep it simple and clear!
    I’d like to achieve when i click button, tween must work idk what is problem
  2. What is the issue? Include screenshots / videos if possible!
    I have no idea why it’s not work, i already used that script for tweening
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

my tween code

local button = script.Parent
local Bar = game.StarterGui.MissionsGUI.Bar.BarImage
local Mission1 = game.StarterGui.MissionsGUI:FindFirstChild("Mission1")

button.MouseButton1Click:Connect(function()
	local TweenService = game:GetService("TweenService")
	Bar:TweenPosition(UDim2.new(0.05, 0,1.803, 0),"Out","Sine",2,false)
	Mission1:TweenPosition(UDim2.new(0.05, 0,1.803, 0),"Out","Sine",2,false)
end)

You’re defining the instances to tween in the StarterGui service
StarterGui is replicated to the client which becomes PlayerGui
instead you would do game.Players.LocalPlayer.PlayerGui

also recommend the following:

  1. define your services at the top of your script not inside functions (less messy)
  2. define the screenGUI in playergui so you can define variables like this:
    local MissionGUI = script.Parent
    local Bar = MIssionGUI.Bar.BarImage

Bruh thanks, just forgot about that

Hmm still don’t work

local button = script.Parent
local Bar = game.Players.LocalPlayer.MissionsGUI.Bar
local Mission1 = game.Players.LocalPlayer.MissionsGUI.Mission1

button.MouseButton1Click:Connect(function()
	local TweenService = game:GetService("TweenService")
	Bar:TweenPosition(UDim2.new(0.05, 0,1.803, 0),"Out","Sine",2,false)
	Mission1:TweenPosition(UDim2.new(0.05, 0,1.803, 0),"Out","Sine",2,false)
end)

in the first post it was Bar.BarImage

it’s frames. and atleast second must work

I changed that, but it didn’t work

where is your local script located, and what is the error message in console. nothing is wrong
with how you’re using the tween so the issue is with your variables or script location

No error in console, script located in text button. image

ok

show me where “bar” and “mission1” are
is the position its going to different from its current position

image

nvm i just reread the code. “game.Players.LocalPlayer.MissionGUI”

you need to do game.Players.LocalPlayer.PlayerGui

Oh lol i forgot , am dumb loool

Finally! But i have still question, how do i make reverse? Just like i click that button and it appear, click again dissapear

Copy that tween but script it twice.

ok understood thanks a lot(30 letters)

1 Like
local button = script.Parent
local Bar = game.Players.LocalPlayer.MissionsGUI.Bar
local Mission1 = game.Players.LocalPlayer.MissionsGUI.Mission1

--
local BarPos = Bar.Position
local Mission1Pos = Mission1.Position

button.MouseButton1Click:Connect(function()
	local TweenService = game:GetService("TweenService")
	Bar:TweenPosition(UDim2.new(BarPos),"Out","Sine",2,false)
	Mission1:TweenPosition(UDim2.new(Mission1Pos),"Out","Sine",2,false)
end)

This won’t fix your issue, but you should declare a variable for the TweenService outside of the definition of a connected function, like this:

local button = script.Parent
local Bar = game.StarterGui.MissionsGUI.Bar.BarImage
local Mission1 = game.StarterGui.MissionsGUI:FindFirstChild("Mission1")
local TweenService = game:GetService("TweenService")

That allows for it to be referenced by the entire script.