local player = game.Players.LocalPlayer
local uis = game:GetService('UserInputService')
uis.InputBegan:connect(function(key,gameproc)
if not gameproc and key.KeyCode == Enum.KeyCode.R then
if player.PlayerGui:FindFirstChild('Main').Chakra.Value < 230 then
script.Disabled = true
script.Disabled = false
print('Not Enough Chakra')
elseif player.PlayerGui:FindFirstChild('Main').Chakra.Value >= 230 then
script.Disabled = false
script.Disabled = true
local anim = Instance.new("Animation")
anim.AnimationId = 'rbxassetid://886524264'
local loadanim = player.Character.Humanoid:LoadAnimation(anim)
repeat wait() until player.Character.Humanoid ~= nil
loadanim = player.Character.Humanoid:LoadAnimation(anim)
loadanim:Play()
player.Character.Humanoid.WalkSpeed = 42
player.PlayerGui:FindFirstChild('Main').Chakra.Value = player.PlayerGui:FindFirstChild('Main').Chakra.Value - 260
local x = Instance.new("Part", game.Workspace)
x.BrickColor = BrickColor.new("Electric blue")
x.Transparency = 1
x.Material = "Neon"
x.FormFactor = "Custom"
x.Shape = "Ball"
x.Name ="Chidori"
x.CanCollide = false
x.Size = Vector3.new(1.36, 1.36, 1.36)
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.CFrame = player.Character['Left Arm'].CFrame
local cb = script.ChakraBall:Clone()
cb.Parent = x
local l1 = script.Lightning1:Clone()
l1.Parent = x
local l2 = script.Lightning2:Clone()
l2.Parent = x
local w = Instance.new("Weld")
w.Name = "ChaWeld"
w.Parent = x
w.Part0 = x
w.Part1 = player.Character['Left Arm']
w.C0 = CFrame.new(0,1.2,0)
game.Debris:AddItem(x,7)
wait(7)
loadanim:Stop()
script.Disabled = false
player.Character.Humanoid.WalkSpeed = 16
end
end
end)
so when you press R an attack should be activated . But if you keep pressing the key it will take energy(chakra) for nothing and its just wasting the energy how do I fix that i tried a lot of ways aka variable enabled = true and things like that I can't seem to understand it
In a simple way How do I make it so when the attack is on and you keep pressing the key it won't waste any energy until the attack is off
Thanks If you tried doing something !

2 comments
script.Disabled = true will make the entire script stop running and it won't start again unless you call .Disabled = false from a different script. Having script.Disabled = false in the same script wont work.
So what do you suggest ? making it in another script inside the localscript(the main one)