How To Tween any gui?

how do i make the speed the same no matter how far or how close the position it’s tweening is?

also i wrote the code in the forum not in studios. If i was in studios i wouldnt do that incorrectly it was just an example for my issue

im tired rn‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎

4 Likes

So you’re unable to tell me how? Do i have to make some complex math script that calculates the amount of seconds i put or something? Are you sure there’s nothing built in.

local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(1) 
local Position = {UDim2.new(0.5,0,0.5,0)}
-- i want it the same speed no matter how far it is or close
local PlayThis = TweenService:Create(Script.Parent, TweenInfo, Position)

u forgot the brackets ‎ ‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‏‏‎

brackets are not required, as of Lua 5.4.4

(oh wait they might be for the TweenService)

How do i make the tween play as fast as it would play for an object close or far away? It speeds up when something is close and slows down when something is far

yeah‎ its part of TS‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎

How do i make the tween play as fast as it would play for an object close or far away? It speeds up when something is close and slows down when something is far

uh maybe u should use some math‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎‎ ‏‏‎

Hey for some reason I’m getting the error entitled:

Unable to cast to Dictionary  -  Client - LocalScript:177

the script is

local Position = UDim2.new(0.725, 0,0.753, 0)
local tweenservice = game:GetService("TweenService")
local Info = TweenInfo.new(2)

local PlayThis = tweenservice:Create(Box,Info,{Position}) -- ERROR HERE
PlayThis:Play()
PlayThis.Completed:Wait()

You can use GuiObject:TweenPosition,

local endPosition = UDim2.new(0.725, 0,0.753, 0)

script.Parent:TweenPosition(endPosition)
1 Like

This is true but it is not good for what I’m trying to do and It’s very bad practice to use. I need to learn how to actually tween and not use noob functions. It’s lazy and embarrassing to use if other scripters or even hackers view your code and will give extreme bad rep. It basically tells anyone who understands code that you don’t understand code.

is more optimizated whe u use guiobject:tweenposition() than use tween service and also reduce code lines so…

1 Like

It’s a supported function, it behaves exactly like normal tweening and it doesn’t show that you “don’t understand code”. I still use it in new projects because its quick and easy, much easier than calling tween service.

Anyways, here is a hopefully working script.

local tweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1)

local PlayThis = tweenService:Create(Path.To.Ui.Object,Info,{ Position = UDim2.new(New.Position.Here) })
PlayThis:Play()
PlayThis.Completed:Wait()

the Udim2 is a variable named position

Okay, so change the UDim2 to the position variable.

How do i make it so that the tween is always the same speed no matter how far the gui is?

Knowing that ‘Speed = Distance / Time’ you just need to configure both tweens such that they share the same time duration.

2 Likes

Try this.

local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut) 
local Position = {Position = UDim2.new(0.5,0,0.5,0)}
-- i want it the same speed no matter how far it is or close
local PlayThis = TweenService:Create(Script.Parent, TweenInfo, Position)
4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.