I want to include a properly working delay to this laser script. I used script.Disabled, but it seems to have a few inconsistantcies. Any ideas?
mouse.Button1Down:connect(function() tool.Ammo.Value = tool.Ammo.Value - 1 tool.Handle.Fire:Play() local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 2048) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local beam = Instance.new("Part", workspace) beam.BrickColor = tool.NeonLight.BrickColor beam.FormFactor = "Custom" beam.Material = "Neon" beam.Transparency = 0 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (tool.Handle.CFrame.p - position).magnitude beam.Size = Vector3.new(0.1, 0.1, distance) beam.CFrame = CFrame.new(tool.Barrel.CFrame.p, position) * CFrame.Angles(math.rad(math.random(-SpreadAngle,SpreadAngle)), math.rad(math.random(-SpreadAngle,SpreadAngle)), 0) * CFrame.new(0, 0, -distance/2) game:GetService("Debris"):AddItem(beam, 0.1)
Hi KingPig,
local deb = false; local del = 2; -- This is the delay it will have. function do_it() if not deb then deb = true; print("Can do it."); wait(del); deb = false; end end mouse.Button1Down:Connect(do_it);
Thanks,
Best regards,
~~ KingLoneCat