Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Gui tweening not working properly?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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!

Ad
Log in to vote
0
Answered by 5 years ago

The S in sine needed to capitalize.

Answer this question