This script has been taken from another Post. The post had a good explanation on how to create the shooting part (Its a module script)
local bullet = Instance.new("Part", workspace)
bullet.Size = Vector3.new(0.06, 0.06, 4)
bullet.Anchored = true
bullet.CanCollide = false
bullet.Color = Color3.new(0, 0, 0)
bullet.Material = Enum.Material.Neon
bullet.Parent = game.Workspace
bullet.CFrame = CFrame.new(Vector3.new(origin.X, origin.Y+0.1, origin.Z), endposition)
local Loop
Loop = game:GetService("RunService").RenderStepped:Connect(function(dt)
local Hit = game.Workspace:Raycast(bullet.Position, bullet.CFrame.LookVector * velocity * 1.5)
if Hit then
if Hit.Instance.Parent:FindFirstChild("Humanoid") then
--Handle Damage
bullet:Destroy()
Loop:Disconnect()
else
-- Hit a Wall
bullet:Destroy()
Loop:Disconnect()
end
end
-- Position Thing
bullet.CFrame *= CFrame.new(0,0, -velocity*(dt*60) )
if (bullet.Position - origing).magnitude > 50000 then
bullet:Destroy()
Loop:Disconnect()
end
end)
i dont want the bullets to be destroyed, i want the bullets to still show up even if the distance is greater than 50 but making the bullet not teleport