Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my debounce not working properly?

Asked by 8 years ago

This script creates a fireball and launches it from your hand. It works great, but I'm having a problem with the debounce. If I press Q once and launch one fireball, the debounce waits three seconds like it should, but if I press Q multiple times, a bunch of fireballs will launch, and then wait. What am I doing wrong?

001local Player = game.Players.LocalPlayer
002local Mouse = Player:GetMouse()
003local Debounce = true
004 
005local UIS = game:GetService("UserInputService")
006 
007UIS.InputBegan:connect(function(Key, GPE)
008    if Key.KeyCode == Enum.KeyCode.Q and not GPE then
009        if Debounce == true then
010 
011            local Animation = Player.Character.Humanoid:LoadAnimation(script.Animation)
012            Animation:Play()
013 
014        local Part = Instance.new("Part", game.Workspace)
015        Part.CFrame = Player.Character["Right Arm"].CFrame * CFrame.new(0, 0, -2)
View all 122 lines...

1 answer

Log in to vote
1
Answered by 8 years ago

I'm not sure if this is right but try putting

1Debounce = false

in the beginning after

1if Debounce == true then
0
It works. Thanks! chia_pet 24 — 8y
Ad

Answer this question