I recently I’ve scripted some guns for my game and the projectile that gets created sometimes doesn’t come from the shootpart (part at the end of the barrel) of my gun and instead from the worlds origin (0,0,0). Any reason that this is happening?
I’ve provided snippets of code below to help.
--Arguments passed through remote (Client above, server below)
FireWeaponRemote:FireServer(script.Parent.Name, MousePosition, script.Parent.Handle.ShootPart.Position)
FireWeaponRemote.OnServerEvent:Connect(function(Player, Weapon, MousePosition, ShootPartPosition)
--Creating Ray
local ProjectileBlacklist = Player.Character
local ProjectileDistance = (MousePosition - ShootPartPosition)
local Projectile = Ray.new(ShootPartPosition, (ProjectileDistance).unit *RefrenceWeapon.Range.Value)
local Collision, CollisionPosition = game.Workspace:FindPartOnRay(Projectile, ProjectileBlacklist, false, true)
--Projectile (beam that comes out of the gun that's messing up)
ProjectileTrail.Size = Vector3.new(0.05, 0.05, ProjectileDistance.Magnitude)
ProjectileTrail.CFrame = CFrame.new(ShootPartPosition, CollisionPosition) * CFrame.new(0, 0, -ProjectileDistance.Magnitude/2)

