RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"pistol"
-- local script for the pistol local tool = script.Parent local mouse = nil local canShoot = true local bulletSpeed = 100 local cooldown = 0.5 local function shoot() if canShoot then canShoot = false local bullet = Instance.new("Part") bullet.Size = Vector3.new(0.2, 0.2, 0.2) bullet.BrickColor = BrickColor.new("Bright red") bullet.Position = tool.Handle.Position bullet.Parent = game.Workspace bullet.Anchored = false bullet.CanCollide = false bullet.Shape = Enum.PartType.Ball local bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) bodyVelocity.Velocity = (mouse.Hit.p - tool.Handle.Position).unit * bulletSpeed bodyVelocity.Parent = bullet game.Debris:AddItem(bullet, 2) wait(cooldown) canShoot = true end end tool.Equipped:Connect(function() mouse = tool.Parent:GetMouse() mouse.Button1Down:Connect(shoot) end)