Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Gui tweening not working properly?

Should it tween the gui? should it not?

local PG = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local Newgui = PG.LeaderBoards.CC
script.Parent.MouseButton1Click:connect(function(player)
script.Parent.Parent:TweenPosition(UDim2.new(10,0,0), "Out", "sine", 3)
end)

2 answers

Hey there!

To start off, when dealing with the client, you want to use a local script.

Now that you are using a Local Script. You want to get the player and other GUI's through variables like you already have:

local plr = game.Players.LocalPlayer 
local PlayerGui = plr:WaitForChild('PlayerGui')
local Newgui = PlayerGui:WaitForChild('LeaderBoards').CC

local Button = script.Parent

script.Parent.MouseButton1Click:connect(function(player)
script.Parent.Parent:TweenPosition(UDim2.new(10,0,0), "Out", "sine", 3)
end)

Now we have to USE the variables and correct some errors:

local plr = game.Players.LocalPlayer 
local PlayerGui = plr:WaitForChild('PlayerGui')
local Newgui = PlayerGui:WaitForChild('LeaderBoards').CC

local Button = script.Parent

Button.MouseButton1Click:Connect(function() -- The First Argument is not player and use :Connect not :connect
	Button.Parent:TweenPosition(UDim2.new(10,0,0,0), "Out", "Sine", 3) -- not sure if this will effect but captialize "S" Also UDIM2 has 4 values
end)

And now with this fixed script, it should work if you got everything correct in terms of variables.

Final Script:

local plr = game.Players.LocalPlayer 
local PlayerGui = plr:WaitForChild('PlayerGui')
local Newgui = PlayerGui:WaitForChild('LeaderBoards').CC

local Button = script.Parent

Button.MouseButton1Click:Connect(function()
	Button.Parent:TweenPosition(UDim2.new(10,0,0,0), "Out", "Sine", 3)
end)

Hopefully, this has helped you learn from your mistakes.

Best of luck developer!

This discussion is preserved as it was. New answers, comments, and votes are closed.