local tool = script.Parent local player = game:GetService("Players").LocalPlayer local oGUI = script:FindFirstChild("ScreenGui") local db = false tool.Equipped:Connect(function(mouse) local GUI = oGUI:Clone() GUI.Parent = player.PlayerGui wait(1) GUI.Equiping.Visible = false mouse.Button1Down:connect(function() if not db == true then db = true local ray = Ray.new(tool.Glowstone.CFrame.p, (mouse.Hit.p - tool.Glowstone.CFrame.p).unit * 400) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local beam = Instance.new("Part",workspace) beam.FormFactor = "Custom" beam.Material = "Ice" beam.BrickColor = BrickColor.new("Cyan") beam.CanCollide = false beam.Anchored = true beam.Transparency = 0.15 beam.Locked = true local distance = (tool.Glowstone.CFrame.p - position).magnitude beam.Size = Vector3.new(0.3 , 0.3 , distance) beam.CFrame = CFrame.new(tool.Glowstone.CFrame.p, position) * CFrame.new(0,0, -distance /2) game:GetService("Debris"):AddItem(beam, 0.1) if part then local human = part.Parent:FindFirstChild("Humanoid") if not human then human = part.Parent.Parent:FindFirstChild("Humanoid") end if human then human:TakeDamage(3) human.WalkSpeed = 1 wait(1) GUI.Time.Visible = true GUI.Time.Text = "4" wait(1) GUI.Time.Text = "3" wait(1) GUI.Time.Text = "2" wait(1) GUI.Time.Text = "1" wait(1) GUI.Time.Visible = false wait(5) db = false end end end end) end)
This is a local script and when i click my mouse it only shoots once
Your issue is that you only check if the value of db is false once, and once you check if it is false, you set it to true. The only time you would set it back to false, according to the code you provided, would be if you hit a player. I would recommend changing your script to this:
local tool = script.Parent local player = game:GetService("Players").LocalPlayer local oGUI = script:FindFirstChild("ScreenGui") local db = false tool.Equipped:Connect(function(mouse) local GUI = oGUI:Clone() GUI.Parent = player.PlayerGui wait(1) GUI.Equiping.Visible = false mouse.Button1Down:connect(function() if not db == true then db = true local ray = Ray.new(tool.Glowstone.CFrame.p, (mouse.Hit.p - tool.Glowstone.CFrame.p).unit * 400) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local beam = Instance.new("Part",workspace) beam.FormFactor = "Custom" beam.Material = "Ice" beam.BrickColor = BrickColor.new("Cyan") beam.CanCollide = false beam.Anchored = true beam.Transparency = 0.15 beam.Locked = true local distance = (tool.Glowstone.CFrame.p - position).magnitude beam.Size = Vector3.new(0.3 , 0.3 , distance) beam.CFrame = CFrame.new(tool.Glowstone.CFrame.p, position) * CFrame.new(0,0, -distance /2) game:GetService("Debris"):AddItem(beam, 0.1) if part then local human = part.Parent:FindFirstChild("Humanoid") if not human then human = part.Parent.Parent:FindFirstChild("Humanoid") end if human then human:TakeDamage(3) human.WalkSpeed = 1 wait(1) GUI.Time.Visible = true GUI.Time.Text = "4" wait(1) GUI.Time.Text = "3" wait(1) GUI.Time.Text = "2" wait(1) GUI.Time.Text = "1" wait(1) GUI.Time.Visible = false wait(5) db = false end end else -- You were missing this mouse.Button1Up:Connect(function() db = false end) end end) end)