-
What do you want to achieve?
I want the bar to fill normally -
What is the issue? When you step back and press, at a moment when the action has not yet completely ended, then for some reason the action continues
-
What solutions have you tried so far?
I tried to change “return false” to “break” but even if everything works, it will not be so convenient
--initiate
if not func:Invoke(player, 5, part) then return end
--server script
local event = game:GetService("ReplicatedStorage").Remotes.ApplyingEvent
local func = game:GetService("ReplicatedStorage").Remotes.ApplyingFunc
local debounce = true
func.OnInvoke = function(player, waittime, part)
if player:IsA("Model") and game:GetService("Players"):GetPlayerFromCharacter(player) then
player = game:GetService("Players"):GetPlayerFromCharacter(player)
end
if player:IsA("Player") then
event:FireClient(player, waittime, true)
debounce = true
delay(waittime, function()
debounce = false
end)
if part then
while debounce do
if (player.Character.HumanoidRootPart.Position - part.Position).magnitude > 10 then
event:FireClient(player, waittime, false)
return false
end
wait()
end
end
return true
end
end
--local (the bar)
local player = game:GetService("Players").LocalPlayer
local gui = player.PlayerGui.MainGUI.CenterFrame.ApplyingFrame
local bar = gui.Frame.Bar
local event = game:GetService("ReplicatedStorage").Remotes.ApplyingEvent
event.OnClientEvent:Connect(function(waittime, bool)
if bool then
gui.Visible = true
bar:TweenSize(UDim2.new(1,0,1,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, waittime)
delay(waittime, function()
bar.Size = UDim2.new(0,0,1,0)
gui.Visible = false
end)
else
bar.Size = UDim2.new(0,0,1,0)
gui.Visible = false
end
end)