Tween doesn't go back after InputEnded triggered

  1. What do you want to achieve?

    Making Frame returning back with UDim2.new after InputEnded is triggered
  2. What is the issue?

    While triggering, i really want it to play animation back when Input is ended
    tried using ‘else’ but seems like it doesn’t work with local function and instead of returning. it will trigger ONLY if i Hold for 1 second, it’ll return back

  1. What solutions have you tried so far?

    as i said using ‘else’ doesn’t work, i’ve been asking 4 Developers but none of them tried to fix it so i have to create a topic here to make sure if i’m missing something else
local TweenEngine = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer
local mouse = Player:GetMouse()

local Aiming = script:WaitForChild("Can")
script.Parent:WaitForChild("CrosshairGui").Enabled = true

local function Tween()
	script.Parent.CrosshairGui.DOT:TweenSize(UDim2.new(0.01,0 ,0.015 ,0),'In', 'Linear', 1)
end

local function Debug()
	script.Parent.CrosshairGui.DOT:TweenSize(UDim2.new(0.02,0 ,0.025 ,0),'In', 'Linear', 1)
	wait(0.1)
	script:WaitForChild("Debug").Disabled = false
end

UserInputService.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then
		script:WaitForChild("Debug").Disabled = true
		script.Parent.CrosshairGui.TextDE.Visible = true
		Aiming.Value = true
		print("Holding")
		Debug()
	end
end)

UserInputService.InputEnded:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then
		script:WaitForChild("Debug").Disabled = false
		Aiming.Value = false
		script.Parent.CrosshairGui.TextDE.Visible = false
		print("Ended")
		Tween()
	end
end)

I think what you are doing is that you click before the animation stops. Before doing the tween in the inputs check if the output tween is finished. If yes, then proceed to the animation. The same as well for output tweens playing before even the input tweens are finished.

i wanted to make sure that while time duration is still active and if i cancel, i want it to play another tween (make it shrink)
i don’t want to hold it for duration of time it was set

In the TweenSize() line, try setting the override parameter to true:
script.Parent.CrosshairGui.DOT:TweenSize(UDim2.new(0.02,0 ,0.025 ,0),'In', 'Linear', 1, true)

Or in the Tween() function, whichever you use to tween it back in:
script.Parent.CrosshairGui.DOT:TweenSize(UDim2.new(0.01,0 ,0.015 ,0),'In', 'Linear', 1, true)

Tldr, just add another parameter “true” to TweenSize function

Got it fixed and there is no issue now
thank you for this

1 Like