-
What do you want to achieve? A debounce for this shield ability
-
What is the issue? whatever I tried, none of it worked
-
What solutions have you tried so far? I’ve tried changing the placing of the debounce around but nothing has worked
here’s my code:
-- services and variables
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local character = player.Character
local mouse = player:GetMouse()
local debounce = false
local ShieldOn = ReplicatedStorage.WandaRemotes:FindFirstChild("WandaShieldOn")
local ShieldOff = ReplicatedStorage.WandaRemotes:FindFirstChild("WandaShieldOff")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://"
local anim = character.Humanoid:LoadAnimation(animation)
local leftGlow = character.LeftHand.Attachment
local rightGlow = character.RightHand.Attachment
local function toggle(value)
leftGlow.a.Enabled = value
leftGlow.b.Enabled = value
leftGlow.c.Enabled = value
rightGlow.a.Enabled = value
rightGlow.b.Enabled = value
rightGlow.c.Enabled = value
end
-- code
UserInputService.InputBegan:Connect(function(input, gameprocessed)
if gameprocessed then return end
if input.KeyCode == Enum.KeyCode.C then
debounce = true
anim:Play()
ShieldOn:FireServer()
end
end)
UserInputService.InputEnded:Connect(function(input, gameprocessed)
if gameprocessed then return end
if input.KeyCode == Enum.KeyCode.C then
anim:Stop()
ShieldOff:FireServer()
end
wait(4)
debounce = false
end)
all help is appreciated!