I am working on making guns, I have already made the guns and at this time am trying to make bullets. I have encountered a problem that the bullet needs rotation. I have tried multiple times to change it by getting the rotation of the gun and getting the lookvector of the players camera neither have worked can i get any help?
script:
script.Parent.Bullet.OnServerEvent:Connect(function(player, looker, damage)
local cframe = script.Parent.Handle.CFrame
local bullet = game.ReplicatedStorage.BulletTest:Clone()
bullet.Parent = game.Workspace.BulletStorage
bullet.CFrame = cframe
bullet.Name = player.Name.."'s Bullet"
bullet.Orientation = Vector3.new(workspace.CurrentCamera.CFrame.LookVector)
print(bullet.Orientation)
local flyer = Instance.new("BodyForce", bullet)
flyer.Force = Vector3.new(0, bullet:GetMass() * 150, 0)
bullet.Velocity = looker * 275
bullet.Touched:Connect(function(hit)
if hit.Name ~= "1911" and hit.Name ~= "Handle" and hit.Name ~= player.Name and hit.Parent.Name ~= player.Name and hit.Name ~= player.name.."'s Bullet" then
bullet:Destroy()
if hit.Parent:FindFirstChild("Durability") then
hit.Parent.Durability.Value -= 1
end
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then
if hit.Name == "Head" then
damage = damage * 2
else
damage = damage
end
hit.Parent.Humanoid:TakeDamage(damage)
if hit.Parent.Humanoid.Health <= 0 then
if hit.Name == "Head" then
player.CashFolder.Cash.Value = player.CashFolder.Cash.Value + 55
player.LevelFolder.XP.Value = player.LevelFolder.XP.Value + 35
else
player.CashFolder.Cash.Value = player.CashFolder.Cash.Value + 15
player.LevelFolder.XP.Value = player.LevelFolder.XP.Value + 10
end
end
end
end
end
end)
game.Debris:AddItem(bullet, 8)
wait()
end)