This tool launches a fire ball from your hand. Mr problem is that it keeps working even after I unequip it. How do I fix it?
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Debounce = true
local UIS = game:GetService("UserInputService")
script.Parent.Equipped:Connect(function()
UIS.InputBegan:connect(function(Key, GPE)
if Key.KeyCode == Enum.KeyCode.Q and not GPE then
if Debounce == true then
Debounce = false
local Animation = Player.Character.Humanoid:LoadAnimation(script.Animation)
Animation:Play()
local Part = Instance.new("Part", game.Workspace)
Part.CFrame = Player.Character["Right Arm"].CFrame * CFrame.new(0, 0, -2)
Part.Anchored = true
Part.Transparency = 1
Part.CanCollide = false
Part.Size = Vector3.new(0.8, 0.8, 0.2)
Player.Character.Humanoid.WalkSpeed = 0
local Decal = Instance.new("Decal", Part)
Decal.Texture = "rbxassetid://301362847"
local Decal2 = Instance.new("Decal", Part)
Decal2.Texture = "rbxassetid://301362847"
Decal2.Face = "Back"
for i = 1, 11 do
Part.Size = Part.Size + Vector3.new(0.5,0.5,0)
wait()
end
local FireBall = Instance.new("Part", game.Workspace)
FireBall.CFrame = Part.CFrame * CFrame.new(0,0,-3)
FireBall.Transparency = 1
FireBall.Size = Vector3.new(1.2, 2.4, 0.8)
local Sound = Instance.new("Sound", FireBall)
Sound.SoundId = "rbxassetid://182382770"
Sound:Play()
local Fire = script.ParticleEmitter:Clone()
Fire.Parent = FireBall
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.Velocity = Mouse.Hit.lookVector * 80
BodyVelocity.Parent = FireBall
FireBall.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(40)
FireBall:Destroy()
elseif
hit.CanCollide == true then
local Explosion = Instance.new("Explosion", game.Workspace)
Explosion.Position = hit.Position
local Sound3 = Instance.new("Sound", hit)
Sound3.SoundId = "rbxassetid://304529688"
Sound3:Play()
for i, v in pairs(hit.Parent:GetChildren()) do
print(v)
local FindFire = v:FindFirstChild("Fire")
if not FindFire then
local GiveFire = Instance.new("Fire", v)
GiveFire.Name = "GiveFire"
end
end
FireBall:Destroy()
wait(2)
for x, y in pairs(hit.Parent:GetChildren()) do
local DeleteFire = y:FindFirstChild("GiveFire")
if DeleteFire then
DeleteFire:Destroy()
end
end
end
end)
wait(0.70)
for x = 1, 15 do
Part.Size = Part.Size - Vector3.new(0.5,0.5,0.5)
wait()
end
Part:Destroy()
Player.Character.Humanoid.WalkSpeed = 16
wait(3)
Debounce = true
end
end
end)
end)
--??
script.Parent.Unequipped:Connect(function()
UIS.InputBegan:connect(function(Key, GPE)
if Key.KeyCode == Enum.KeyCode.Q and not GPE then
Debounce = false
end
end)
end)

1 comment
Ignore the debounce = false at the end. I was just trying things to fix it.