How to make ui tween in then back out?

Hello,

I’m polishing my crosshair and I want it so that when you click, the crosshair size increases and goes back to normal fast. Problem is I don’t know how to make it tween in and out simply.

	local TweenCrosshairInOut = TweenService:Create(
		CrosshairImage,
		TweenInfo.new(
			0.1,
			Enum.EasingStyle.Quint,
			Enum.EasingDirection.InOut),
		{Size = UDim2.new(0,10,0,10)},
	)
	
	UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean) 
		if gameProcessedEvent then
			return
		end

		if input.UserInputType == Enum.UserInputType.Touch or
			input.UserInputType == Enum.UserInputType.MouseButton1
		then
			TweenCrosshairInOut:Play()
			
			if input.UserInputType == Enum.UserInputType.Touch then

			end
		end
	end)
1 Like

try this

change the 0.5 to however number you want.

local tween = TweenService:Create(CrosshairImage, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true),{Size = CrosshairImage.Size + UDim2.new(0, CrosshairImage.Size.Y.Offset * 0.6, 0, CrosshairImage.Size.Y.Offset * 0.6)})
	
	UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean) 
		if gameProcessedEvent then
			return
		end

		if input.UserInputType == Enum.UserInputType.Touch or
			input.UserInputType == Enum.UserInputType.MouseButton1
		then
			tween:Play()
			
			if input.UserInputType == Enum.UserInputType.Touch then

			end
		end
	end)
2 Likes

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