Pan_domix
(Enix)
December 27, 2022, 1:55am
#1
I was doing a opening and closing button for a ui but it doesn’t work due to a error
Here is the Script:
local Player = game.Players.LocalPlayer
local MainFrame = Player.PlayerGui:WaitForChild("HelpButton").MainFrame
script.Parent.MouseButton1Up:Connect(function()
if MainFrame.Visible == false then
MainFrame.Visible = true
MainFrame:TweenPosition(
UDim2.new(0.394, 0, 0.338, 0),
"Elastic",
"Out",
0.5,
true
)
elseif MainFrame.Visible == true then
MainFrame:TweenPosition(
UDim2.new(0.394, 0, 1, 0),
"Elastic",
"Out",
0.5,
true
)
wait(0.5)
MainFrame.Visible = false
end
end)
Any help would be appreciated
Instead of TweenPosition, why don’t you use TweenService?
game:GetSerivce("TweenService"):Create(MainFrame, TweenInfo.new(0.5), {Position = UDim2.new(0.394, 0, 0.338, 0)}):Play() -- Snippet
--TweenInfo.new(0.5, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0.5, true)
1 Like
DasKairo
(Cairo)
December 27, 2022, 2:01am
#3
Flip the EasingDirection
and EasingStyle
"Out", -- First
"Elastic" -- Second
Also I recommend using UDim2.fromScale
if you are only using the Scale
DasKairo
(Cairo)
December 27, 2022, 2:02am
#4
TweenPosition
is TweenService
but for UI’s?
It’s deprecated and much better off to use tweenservice as a whole instead.
Not to mention it has more proprieties to tween.
https://create.roblox.com/docs/reference/engine/classes/GuiObject#TweenPosition
1 Like
DasKairo
(Cairo)
December 27, 2022, 2:11am
#6
TweenPosition
isnt Deprecated.
Either way in this Case, it will make no Difference, Those “Extra” Properties (Ex: Reversable and Delay) Are never really used either
Tweening rotation is never used in guiobjects…? Okay…
Also TweenPosition
is a boolean unlike tweenservice’s animation tween where you can freely control it, such as loop it, pause it or fire a connection when it ends.
1 Like
local Player = game.Players.LocalPlayer
local MainFrame = Player.PlayerGui:WaitForChild("HelpButton").MainFrame
local TweenService = game:GetService("TweenService")
script.Parent.MouseButton1Up:Connect(function()
if MainFrame.Visible == false then
MainFrame.Visible = true
TweenService:Create(MainFrame, TweenInfo.new(0.5, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out), {Position = Udim2.fromScale(0.394, 0.338)}):Play()
elseif MainFrame.Visible == true then
TweenService:Create(MainFrame, TweenInfo.new(0.5, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out), {Position = Udim2.fromScale(0.394,1)}):Play()
wait(0.5)
MainFrame.Visible = false
end
end)
Try this out. It uses TweenService
instead of the built-in TweenPosition()
.
DasKairo
(Cairo)
December 27, 2022, 2:14am
#10
That’s not how that works, You are not allowed to use Strings for EasingStyle
and EasingDirection
with TweenService
eatabler0ck
(eatablerock)
December 27, 2022, 2:15am
#11
There, replaced it with the Enum
variants.
Pan_domix
(Enix)
December 27, 2022, 11:21am
#12
Yess that was indeed the problem…I faced this problem so many times in the past and I was able to fix it but since I wasn’t on for a while I forgot…But I did remember it’s something simple no big change in the code, Perfect answer, Thank you so much mate
Pan_domix
(Enix)
December 27, 2022, 11:22am
#13
It’s much more work why do that instead of just doing it directly
Pan_domix
(Enix)
December 27, 2022, 11:23am
#14
I would use it if it’s parts or properties of stuff…But it’s ui and it’s much simpler to use tween position and I knew that wasn’t the case…But thank you for the recommendation
WHYI_MFAT
(WHYI_MFAT)
January 8, 2023, 7:24pm
#15
Hey,
Welcome to ME UI!!
DOWNLOAD - v1.0
What Is ME UI?
ME UI is a plugin which can easily make animations to gui!
What does ME UI offer?
ME UI offers the fastest to create gui animations and the best!
Why should I use it?
Because You Can’t Find Plugin Work Like ME UI
this plugin is the best you can find for gui animations
ME UI have all you need
What does it help?
It helps for make gui animations eazy
[image]
LINK: click here for going to roblox plugin page
EXAMPLES:
Cool Gui Ani…
this is eazy plugin to create ui animation
system
(system)
Closed
January 22, 2023, 7:24pm
#16
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.