Crrustyy
(boblox_man)
April 5, 2020, 2:07pm
#1
Hey!
I am trying to make a gui pop up using TweenPosition
but the “animation” does’t load in.
Here is my code:
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local gui = game.StarterGui.Starter
gui.Parent = playerGui
script.Parent.MouseButton1Click:Connect(function()
local cook = gui.CookFrame
cook:TweenPosition(UDim2.new(0,0,1,0)"InOut","Linear",0.5)
end)
It doesn’t show up when I press the button.
Any help?
2 Likes
Crrustyy
(boblox_man)
April 5, 2020, 2:07pm
#2
Im guessing InOut makes it go away, but what is the alternative to make it appear?
1 Like
Startergui clones all the guis to the playerguis for you, you’re not supposed to do this.
Instead do:
local gui = PlayerGui.Starter
1 Like
Crrustyy
(boblox_man)
April 5, 2020, 2:20pm
#4
Hmm.
There is nothing in the output - maybe I should try print statements?
The updated code is:
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local gui = playerGui.Starter
script.Parent.MouseButton1Click:Connect(function()
local cook = gui.CookFrame
cook:TweenPosition(UDim2.new(0,0,1,0)"InOut","Linear",0.5)
end)
What should I try next?
1 Like
You’re missing a comma before the “InOut” part.
1 Like
Crrustyy
(boblox_man)
April 5, 2020, 2:32pm
#6
I have tried that - and yet the same result.
I will try debug it and get back to you all.
2 Likes
Abroxus
(Abroxus)
April 5, 2020, 2:34pm
#7
Is it a local script or a script?
1 Like
Crrustyy
(boblox_man)
April 5, 2020, 2:34pm
#8
This is a local script inside of the button.
1 Like
local PlayerGUI = game.Players.LocalPlayer.PlayerGui
script.Parent.MouseButton1Click:Connect(function()
local CookFrame = PlayerGUI.CookFrame
CookFrame:TweenPosition(UDim2.new(0,0,0.5,0),"InOut","Linear",0.5)
end)
try this now.
1 Like
Abroxus
(Abroxus)
April 5, 2020, 2:35pm
#10
Does the output show the error of the script?
1 Like
Crrustyy
(boblox_man)
April 5, 2020, 2:36pm
#11
Nope, no errors, I have tried print statements but i don’t think I did them correctly hahaha.
1 Like
Abroxus
(Abroxus)
April 5, 2020, 2:38pm
#12
Maybe use the WaitForChild function when wanting the playerGUI because it might not load straight away.
local PlayerGUI = game.Players.LocalPlayer:WaitForChild(“PlayerGui”)
1 Like
local TweenService = game:GetService("TweenService")
local TweenAnimation = Tweeninfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false)
local PlayerGui = game.Players.LocalPlayer.PlayerGui
script.Parent.MouseButton1Click:Connect(function()
local Frame = PlayerGUI.CookFrame
local Tween = TweenService:Create(Frame, TweenAnimation, {Position = UDim2.new(0,0,0.5,0)})
Tween:Play()
end)
If still experiencing errors, try advanced version of Tweening.
2 Likes
It must be loaded because Parent of this script is PlayerGui, which loads faster than script.
1 Like
Crrustyy
(boblox_man)
April 5, 2020, 2:42pm
#15
Ok, is there any way to find what Tweeninfo
is? Is it part of TweenService or?
It is DataType. like option of tweening. TweenInfo
Crrustyy
(boblox_man)
April 5, 2020, 2:46pm
#17
Yes, my bad - I just made a typo that’s all.
Ill see if this works!
1 Like
Crrustyy
(boblox_man)
April 5, 2020, 2:48pm
#18
Hmmm. Still nothing…
Would this sort of script work on a SurfaceGui on a part?
Hmm. These sort of script will work in GUI object if all of object is set correctly.
Afaik, SurfaceGuis won’t register mouse inputs if the Adornee property of the SurfaceGui isn’t specified. The Adornee property should be the part that the surface gui is attached to