I'm just starting with lua coding, so the code can be very poorly written, but how to debounce this? I'm already tried several ways that turned out to be a failure so I decided to write about it here.
UIS.InputBegan:Connect(function(key,gameProcessed)
if gameProcessed then return end
if key.KeyCode == Enum.KeyCode.Z then
char = plr.Character or plr.CharacterAdded:Wait()
hum = char:WaitForChild('Humanoid')
if char then anim = hum:LoadAnimation(animInst) end
anim:Play()
anim.KeyframeReached:connect(function(keyframename)
if keyframename == 'Pause' then
anim:AdjustSpeed(0)
end
end)
end
end)
UIS.InputEnded:Connect(function(key,gameProcessed)
if gameProcessed then return end
if key.KeyCode == Enum.KeyCode.Z then
anim:Stop()
castMagic(plr, mouse.Hit.Position)
end
end)

1 comment
debounce = false not debounce == false