thank you so much, I’ll try it!
anytime let me know if any problems happen with my coding. I did a few tests to make sure it works :)*
can you a short video how you did it or not?
I just don’t know where to put the script
local TS = game:GetService("TweenService")
local on = false
script.Parent.MouseButton1Click:Connect(function()
if on then on = false
TS:Create(script.Parent.Parent.Frame,TweenInfo.new(1),{Position = UDim2.new(0,0,0.5,0)}):Play()
else on = true
TS:Create(script.Parent.Parent,TweenInfo.new(1),{Position = UDim2.new(0.5,0,0.5,0)}):Play()
end
end)
I edited his code. Just paste this into your existing one
he has a different setup of where his frames are.
Ah my bad, I wasn’t really paying attention to what he sorted his layout as.
I am very confused now. My dad told me to stop, bye guys and thx for your help! I’ll try fix it tomorrow
Alright! ( ignore this to add chars) :)*
Will you guys be able to help me tomorrow to?
Sure can this is super easy, I’ll give you a better explanation while you’re gone.
TweenService
How to use it and how to code it.
- Get better details from the site here
- You can also find more on their site full of tutorials : )
Roblox Site Tutorial
This is only for details about how to use TweenService by Roblox’s Sites shown.
- TweenService is able to be used for frames, parts, values, and ect.
- They require goals and a time and a connected object for the tween.
- They can be paused or played
Information
-
TweenService can be used in different styles for your direction and easing.
-
They’re also able to tween in Local Scripts and Server Scripts
Shown here:
Tip:
You should make the tween connected to a variable if you’d like to wait for it to stop after it’s done tweening.
- TweenService does require a object connected with a goal and time to finish.
The coding is actually very simple for most people, this is why I’m showing the site to search on how to use it and what it requires and does.
Now, let’s get to the coding process.
Coding
Since we want to tween with a out and in positioning for the frame, we should start off with doing this:
local TweenService = game:GetService("TweenService")
The main important thing about this is that we need to get TweenService otherwise it will not work because the service is required for us to be allowed to tween objects.
Now lets add more variables to help out.
local TweenService = game:GetService("TweenService")
local Frame = script.Parent:WaitForChild("Frame")
local Button = script.Parent:WaitForChild("TextButton")
What we’re doing now is waiting for the Frame and Button to appear for the UI, so it’s ready for us to use once tween the object, but I didn’t put it in any frame or button because we’re doing script.Parent.Frame or script.Parent.Button and not script.Parent.Parent.Frame otherwise I’d be placed in the button.
Let’s continue this,
local TweenService = game:GetService("TweenService")
local Frame = script.Parent:WaitForChild("Frame")
local Button = script.Parent:WaitForChild("TextButton")
local Enabled = false -- We're detecting if it's enabled or not.
Button.MouseButton1Click:Connect(function()
end)
We’ve added a detection and a mouse button detection when clicked, we’re now going to start adding the necessary things to tween the part.
local TweenService = game:GetService("TweenService")
local Frame = script.Parent:WaitForChild("Frame")
local Button = script.Parent:WaitForChild("TextButton")
local Enabled = false -- We're detecting if it's enabled or not.
local TweenInfoData = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
Button.MouseButton1Click:Connect(function()
if Enabled then -- Checking if Enabled.
Enabled = false -- Disabling the Enabled part on click.
local Tween = TweenService:Create(Frame,TweenInfoData,{Position = UDim2.new(-1,0,0.5,0)})
--[[ Now we've gotten the tween set up, we can start adding the other extra stuff to help out.]]
if Enabled ~= true then -- Checking if not Enabled.
Enabled = true
local Tween = TweenService:Create(Frame,TweenInfoData,{Position = UDim2.new(0.5,0,0.5,0)})
end)
Lets add a debounce to avoid the spamming of the frame,
local TweenService = game:GetService("TweenService")
local Debounce = false
local Frame = script.Parent:WaitForChild("Frame")
local Button = script.Parent:WaitForChild("TextButton")
local Enabled = false -- We're detecting if it's enabled or not.
local TweenInfoData = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
Button.MouseButton1Click:Connect(function()
if Enabled and not Debounce then -- Checking if Enabled.
Debounce = true
Enabled = false -- Disabling the Enabled part on click.
local Tween = TweenService:Create(Frame,TweenInfoData,{Position = UDim2.new(-1,0,0.5,0)})
Tween:Play()
Tween.Completed:Wait()
Debounce = false
--[[ Now we've gotten the tween set up, we can start adding the other extra stuff to help out.]]
else
if Enabled ~= true and not Debounce then -- Checking if not Enabled.
Debounce = true
Enabled = true
local Tween = TweenService:Create(Frame,TweenInfoData,{Position = UDim2.new(0.5,0,0.5,0)})
Tween:Play()
Tween.Completed:Wait()
Debounce = false
end
end
end)
Congrats now we’ve finished! This should work for you to test out on your own stuff and have a better system to work with!
- The Coding will be explained better than last time.
- The Coding has been tested and proven to work
- Do not always follow along with mine as there’s better ways to do this than I can.
Notice: I did mess up because I’m not in roblox studio so grab the full code if you’d like to understand it more or read it all in one but follow along with the fixed one.
Download the Example here:
ExampleTweenService.rbxl (26.9 KB)
Thank you for testing this if clicked, anyway this should be enough helpful advice to keep you steady!
Hello! i hope this helps you
-- TweenService / Tween:
-- These can be used to create animations of many objects.
-- Create a Part in workspace
-- Inside the Part create a "script"
local TweenService = game:GetService("TweenService")
local part = script.Parent
-- This is what TweenInfo will do:
local info = TweenInfo.new(
5, -- Lenght (seconds)
Enum.EasingStyle.Sine, -- Easing style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Times repeated
false, -- Reverse
0 -- Delay (seconds)
)
-- This is the goal of the interpolation (Tween):
local tweenGoal =
{
Size = Vector3.new(15,15,15);
}
-- Reference to animation
-- This is → Part, info and Goals:
local MakePartBiggerTween = TweenService:Create(part, info, tweenGoal)
wait(1) -- wait time
-- Play the Tween Animation:
MakePartBiggerTween:Play()
Omg thank you so much!! Thank you for helping me!!
Is this for tweening a part or not?
Create a LocalScript Inside the Button GUI you are using
script.Parent.MouseButton1Click:Connect(function()
local Frame = script.Parent.Parent.FRAME_NAME -- Change FRAME_NAME to your frame your moving. Add A [ .Parent ] if it wont work ex= script.Parent.Parent.Parent OR remove a .Parent
Frame:TweenPosition(UDim2.new(0, 0,0, 0),"Out","Quint",0.5,true) -- Potition to move frame/tween style/ time it takes to move
end)
-- Zentryte
Change the numbers (0, 0,0, 0) to the position of your frame you want to open
These are different Easing styles → EasingStyle
Thank you! (ignore these its for extra lol)
Yes, with this code you use a part and generate an animation with it keeping in mind the beginning and end of the animation (and its changes in the process)
part to be used:
local part = script.Parent
changes in the process:
local info = TweenInfo.new(
5, -- Lenght (seconds)
Enum.EasingStyle.Sine, -- Easing style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Times repeated
false, -- Reverse
0 -- Delay (seconds)
)
The goal (The end of the animation, its goal):
local tweenGoal =
{
Size = Vector3.new(15,15,15);
}
Play tween animation
MakePartBiggerTween:Play()
Alright thank you so much for your help!!!
You’re welcome, I’m also learning and that we all help each other helps a lot