Im very new to lua code so this is probably simple this is the code I have:
01 | local button = game.StarterGui.PlayScrene.Screne.Play |
02 | local PlayButton = game.StarterGui.PlayScrene.Screne.Play |
03 | player = game.Players.LocalPlayer |
04 | local object = game.StarterGui.PlayScrene.Screne |
05 | local click = game.Workspace.Click |
06 | object.Position = UDim 2. new( 0 , -object.Size.X.Offset, 2 , 0 ) |
07 |
08 | button.MouseButton 1 Click:connect( function () |
09 | object:TweenPosition(UDim 2. new(- 0.35 , 0 , 0.35 , 0 )) |
10 | end ) |
Im using a local script in the ScreenGui
(Yes I know some stuff is mispelled)
When I play it, it doesnt do anything when I click the button also if you are wondering the button name is Play.
Thanks
Hello, EmeraldRailYT!
Your script was correctly moving the gui, but you was moving the gui inside game.StarterGui
, that is just the gui that is clonned inside the player when they join.
I just needed to change the gui from game.StarterGui
to game.Players.LocalPlayer.PlayerGui
01 | local player = game.Players.LocalPlayer |
02 | local playerGui = player:WaitForChild( "PlayerGui" ) -- waits for the gui to be clonned inside the player... |
03 |
04 | local button = playerGui.PlayScrene.Screne.Play |
05 | local PlayButton = playerGui.PlayScrene.Screne.Play |
06 | local object = playerGui.PlayScrene.Screne |
07 | local click = game.Workspace.Click |
08 |
09 | object.Position = UDim 2. new( 0 , -object.Size.X.Offset, 2 , 0 ) |
10 |
11 | button.MouseButton 1 Click:connect( function () |
12 | object:TweenPosition(UDim 2. new(- 0.35 , 0 , 0.35 , 0 )) |
13 | end ) |