Scripts not working

so whenever i code my UI they just dont work, but i dont see any errors in the script or the console
they just dont work for some reason, its really annoying and is holding me from making my UI’s i dont know if its just me, i tried tweening my UI with the script i wrote the exact same script it did not work
here is the script

local play = script.Parent

local main = game.StarterGui.inventory.inventory

play.MouseButton1Up:Connect(function()

main:TweenPosition(

UDim2.new(0.235, 0, 0.117, 0),

"Out",

"Quad",

1,

false

)

end)

i refrenced everything properly i use the same script for tweening other GUI’s and they worked but this day none of my scripts are working

1 Like

You are tweening the GUI inside of StarterGui, not inside of the PlayerGui. Here’s how to get the PlayerGui:

local playerGui = game.Players.LocalPlayer.PlayerGui
local main = playerGui.inventory.inventory

Hope this helped!

it does not work, and i did the script that i told on many other GUI’s and they worked i dont know how it does not work this time

When you used PlayerGui, did any errors occur? If so please send it here so I can debug it more easily. Can you also send the GUI hierarchy image? Thanks

there were no errors in the console

There’s the error, play button is argumented inside the button, so its basically in PlayerGui, but “main” is argumented inside StarterGui, so, thats the problem, here is a fix:

local player = game:GetService("Players").LocalPlayer or game:GetService("Players").PlayerAdded:Wait()
local playergui = player:WaitForChild("PlayerGui")

local play = script.Parent
local main = playergui:WaitForChild("inventory").inventory -- This is inside your playergui, that will make the tween visible for you when you press play button.



play.MouseButton1Click:Connect(function() -- You argumented a wrong click detection.
	
	if player then -- We check if player is loaded
		
		main:TweenPosition(

			UDim2.new(0.235, 0, 0.117, 0),

			Enum.EasingDirection.Out, -- I just changed this cause using Enums as strings can yield sometimes, but this is at your election.

			Enum.EasingStyle.Quad,

			1,

			false

		)
		
	end


end)

it worked thank you so much for fixing it