About
Hello, I’ve been trying to code a bar that fills up whenever you are holding left click on a certain part at a certain distance.
So far, I’ve gotten everything accomplished except the bar whenever I release the left mouse button it doesn’t cancel the tween.
What I’ve tried
I’ve tried changing the size on button release, and tweening the opposite direction. I’ve sat here for 30 minutes now thinking what I could be doing to do this, what I should be doing, then trying it but it doesn’t come remotely close to what I need (which is for the Bar to reset back to size of 0, 0, 0.7, 0).
My Code
UIS.InputBegan:Connect(function(InputObject, Processed)
if InputObject.UserInputType == Enum.UserInputType.MouseButton1 then
local distance = (char.HumanoidRootPart.Position - mouse.Target.Position).magnitude
mouseDown = true
while mouseDown == true do
wait()
if mouse.Target.Name == "Canvas" and distance < 10 then
bar.Fill:TweenSize(UDim2.new(0.975, 0, 0.7, 0), "Out", "Linear", speed.Value)
bar.Fill.Size = UDim2.new(0, 0, 0.7, 0)
else
bar.Fill.Size = UDim2.new(0, 0, 0.7, 0)
end
end
if mouseDown == false then
bar.Fill.Size = UDim2.new(0, 0, 0.7, 0)
end
end
end)
--\\ Button Release //--
UIS.InputEnded:Connect(function(InputObject, Processed)
if InputObject.UserInputType == Enum.UserInputType.MouseButton1 and mouse.Target.Name == "Canvas" then
mouseDown = false
bar.Fill.Size = UDim2.new(0, 0, 0.7, 0)
end
end)
I’d greatly appreciate some help on this, I’ve searched the DevForum multiple times, but haven’t found what I am looking for exactly.
Thank you,
-EnDarke