- What do you want to achieve?
I want it so when the player has the football, and if they hold down m1 a meter charges up bit by bit until 12. And when the player shoots, looses the ball or lets go of m1 the meter will reset back to 0.
-
What is the issue?
Right now when you click m1 no matter if you have the ball or not, the meter will go up by itself when having the ball equipped. In the clip, after I shoot and get the ball again, it goes up by itself. But I only want it to go up when I hold down m1.
https://gyazo.com/6f8523afb987427bdf0093abc59c3cd8
-
What solutions have you tried so far?
I have tried to use a while loop instead, and tried to switch around with the debounce, but nothing has worked.
local Player = game.Players.LocalPlayer
local Character = script.Parent
local humanoid = Character.Humanoid
local PlrStats = Player:WaitForChild("PlrStats")
local uis = game:GetService("UserInputService")
local Footwork = (PlrStats.Footwork.Value)
local KickMeter = PlrStats.KickMeter
local debounce = false -- debounce for kickmeter
local kicking = uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
KickMeter.Value = 0
while wait(0.1) do
local hasBall = false
if Character.HumanoidRootPart:WaitForChild("GetBallHitbox"):FindFirstChild("Football") then
hasBall = true
end
if input.UserInputType == Enum.UserInputType.MouseButton1 and hasBall then
debounce = false
repeat
KickMeter.Value += (Footwork) -- The KickMeter max is 12
wait(0.15)
until
KickMeter.Value >= 12 or debounce == true or not hasBall
if KickMeter.Value > 12 then
KickMeter.Value = 12
end
end
end
end)