How to make tween move same speed speed

Hello all,
I am making a fishing system like from stardew valley. Basically though I just need help with using :TweenPosition() and getting the time to change depending on where the moving gui is. e.g. if the green bar is near the top you will go the same amount time as if it would go from the start. After looking around you can use the time = distance/speed formula but thats not working or maybe i’m not doing it right.

local speed = 0.2


press.MouseButton1Down:Connect(function()
	local scale = max.Position.Y.Scale - min.Position.Y.Scale * -1
	
	local toTop = scale - gbar.Position.Y.Scale  --- distance between greenbar to the top
	local toBottom = scale - (scale - gbar.Position.Y.Scale) --- distance between greenbar to the bottom
	
	local Time1 = (toTop)/speed
	local Time2 = (toBottom)/speed
	
	gbar:TweenPosition(max.Position, Enum.EasingDirection.In, Enum.EasingStyle.Linear, Time1, true)
		print(Time1)
	press.MouseButton1Up:Connect(function()
		print(Time2)
		gbar:TweenPosition(min.Position, Enum.EasingDirection.In, Enum.EasingStyle.Linear, Time1, true)
	end)
end)

robloxapp-20230715-1759198.wmv (396.0 KB)

Thanks

1 Like

Fixed it. I will leave the solution cause I hate it when people don’t. I had to move the tobottom variable into the mousebutton1Up event cause it was getting the position from when the move button first went down, but now it is getting the position from when the mouse button goes up. I feel pretty dumb but atleast its working now.

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