local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
enabled = true
Mouse.KeyDown:connect(function(key)
if not enabled then
return
end
if key == "z" then
local Shot = Instance.new("Part", workspace)
Shot.Name = "Shot"
Shot.BrickColor = BrickColor.new("White")
Shot.Transparency = 0
Shot.Anchored = false
Shot.CanCollide = false
Shot.TopSurface = Enum.SurfaceType.SmoothNoOutlines
Shot.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
Shot.Shape = ("Ball")
Shot.Size = Vector3.new(2, 2, 2)
Shot.CFrame = Player.Character.Torso.CFrame*CFrame.new(0,0,0)
Shot.formFactor = Enum.FormFactor.Custom
local AirEffect = Instance.new("Part", Shot)
AirEffect.Name = "Shot"
AirEffect.BrickColor = BrickColor.new("White")
AirEffect.Transparency = 0.5
AirEffect.Anchored = false
AirEffect.CanCollide = false
AirEffect.TopSurface = Enum.SurfaceType.SmoothNoOutlines
AirEffect.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
AirEffect.Shape = ("Ball")
AirEffect.Size = Vector3.new(2.5, 2.5, 2.5)
AirEffect.formFactor = Enum.FormFactor.Custom
AirEffect.CFrame = Player.Character.Torso.CFrame*CFrame.new(0,0,0)
local W = Instance.new("Weld")
W.Part0 = AirEffect
W.Part1 = Shot
W.Parent = AirEffect
W.C0 = CFrame.Angles(0, 0, 0)
local Woosh = Instance.new("BodyVelocity")
Woosh.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Woosh.velocity = Vector3.new(Mouse.Hit.x, Mouse.Hit.y, Mouse.Hit.z)
Woosh.Parent = Shot
end
end)
This Local Script is for a ranged attack. When you press Z it fires a shot to where your mouse is pointing. It works fine however its extremely inaccurate. Please help me improve this.
This is how inaccurate it is: https://gyazo.com/cb7ac35954413ee8c3c866a0a49fa2ca

3 comments
I'm in love with you.
i ship it
I'm okay with this