Hi. I am writing a script that detects how long you held the mouse for and I use it to tween a frames size. I want the frames size to be tweened when the player is holding down the mouse, not after they are done holding down the mouse.
Current script:
UserInputService.InputBegan:Connect(function(Input, GameProcessed)
if not Tool.Enabled then return end
if Input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
if not LeftLeg:FindFirstChild("BallWeld") then return end
if GameProcessed then return end
Tool.Enabled = true
MouseDown = true
StartedDown = tick()
end)
UserInputService.InputEnded:Connect(function(Input, GameProcessed)
if Input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
if not LeftLeg:FindFirstChild("BallWeld") then return end
if GameProcessed then return end
MouseDown = false
Tool.Enabled = false
Duration = tick() - StartedDown
if Duration > 1 then
Duration = 1
end
PowerBar:TweenSize(UDim2.new(Duration , 0 , 1 , 0) , "Out" , "Linear" , 0.4)
if Ball then
Sound:Play()
RemoteEvent:Fire(Ball, Duration)
task.wait(Cooldown)
PowerBar:TweenSize(UDim2.new(0,0,0,29) , "Out" , "Linear" , 0.3)
Tool.Enabled = true
end
end)
Any help would be appriciated, thanks!