Back Easing Style Doesn't Work

in video 1, you can see that the distance doesnt even appear once stepped inside, and on the video 2, it doesnt even work like a normal Back.



in video 1, i used the Easing Direction In, and in video 2 i used Out

any help appreciated

oops, forgot to add the code lol

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
repeat wait() until Player.Character
local Character = Player.Character
local Humanoid = Character.Humanoid
local CollectionService = game:GetService("CollectionService")
local Starters = CollectionService:GetTagged("Start")
local TweenService = game:GetService("TweenService")
local MainGUI = script.Parent.MainGUI
local DistanceHolder = MainGUI.DistanceHolder
local DistanceText = DistanceHolder.Distance

local Distance = 0
local Started = false

local Starter = nil

for _, Start in Starters do
	Start.Touched:Connect(function(Touched)
		if Touched.Parent == Character then
			if not Started then
				task.wait(0.25)
				Started = true
				Starter = Start
				print("Player started the game!")
			else
				task.wait(0.25)
				Started = false
				Starter = nil
				warn("Player ended the game!")
			end
			
			print(Starter)
		end
	end)
end

Humanoid.Died:Connect(function()
	Started = false
end)

while task.wait() do
	if Starter ~= nil then
		if Started then
			TweenService:Create(DistanceHolder, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = UDim2.new(0.5, 0, 0.1, 0)}):Play()
			Distance = (Character.HumanoidRootPart.Position - Starter.Position).Magnitude
			DistanceText.Text = "DISTANCE: "..math.floor(Distance).." M"
		else
			TweenService:Create(DistanceHolder, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {Position = UDim2.new(0.5, 0, 0, 0)}):Play()
		end
	else
		TweenService:Create(DistanceHolder, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {Position = UDim2.new(0.5, 0, 0, 0)}):Play()
	end
end

The problem is probably because your code seems to create a lot of tweens every second. Every task.wait (about 30-40 times a second) if Starter ~= nil and Started, then it creates a new tween. So while this is true 30-40 new tweens are created every second.

New tweens replace/destroy old tweens, so the rate of change of the DistanceHolder’s position over the 1/30 of a second that a given tween exists for is equal to the initial rate of change for the selected style.

Back has a very small rate of change at the start, so each tween created moves the distance virtually zero (it even might move it backwards, but very slowly):


To fix this, you need to wait for the tweens to finish. So replace your tween creation code with something like:

local tween = TweenService:Create(DistanceHolder, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = UDim2.new(0.5, 0, 0.1, 0)})
tween:Play()
tween.Completed:Wait()

This stops a new tween from being created (and replacing the tween created just 1/30 of a second ago) until the tween finishes.

You could also have code to check if the state changes (i.e. the combination of Starter ~= nil and Started changes) and only create a new tween when that happens (not just at every moment those two are true).

this worked flawlessly!!! thank you so much!

1 Like

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