I'm making a script for a gun entirely from scratch, this gun is supposed to be basic, and it doesn't have any sounds or animations. However I keep encountering this bug where the bullets don't spawn in the right place, and they don't travel forwards either
This is the script for the gun itself:
local ReplicatedStorage = game.ReplicatedStorage
local muzzle = game.StarterPack.Gun.Muzzle
function onBulletHit(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Character.Humanoid.Health:TakeDamage(20)
else
hit.Anchored = nil
end
end
ReplicatedStorage.FireBullet.OnServerEvent:Connect(function()
-- Gun characteristics
local gunShot = nil
local fireRate = 1
local bulletDamage = 2
local bulletSpeed = 160
local gunDist = 70
if not gunShot then
gunShot = true
local bullet = ReplicatedStorage.Bullet
local firedBullet = bullet:Clone()
firedBullet.Position = workspace.Part.Position
firedBullet.Parent = workspace
firedBullet.Velocity = muzzle.CFrame.LookVector
print("lol")
firedBullet.Touched:Connect(onBulletHit)
end
end)
Any help would be appreciated

2 comments
multiply the lookVector by 100
@ Mathenotics These types of questions is already answered in the dev forums. Please do some research. Or ask some question(s)