function ProjectileModule.ProjectileStraight(player, model : Model, origin : CFrame, velocity : Vector3, sizecoefficent : Vector3, duration : number, acceleration : Vector3?, params : RaycastParams, destructionbool : boolean, damage : number, explosion : {}, hitinfo : {}, instance, hitposition, debrisbool, rotatebool)
if Connection == nil then
ProjectileModule.Start()
end
local Character = player.Character
if not Character then return end
local Projectile = {}
local Model : Model = ReplicatedStorage.VFX.Models[model]
if Model:IsA("Model") and Model.PrimaryPart then
Projectile.Size = Model.PrimaryPart.Size
elseif Model:IsA("BasePart") then
Projectile.Size = Model.Size
else
Projectile.Size = Vector3.one
end
if typeof(sizecoefficent) == "Vector3" then
Projectile.Size = Vector3.new(Projectile.Size.X * sizecoefficent.X, Projectile.Size.Y * sizecoefficent.Y, Projectile.Size.Z * sizecoefficent.Z)
elseif typeof(sizecoefficent) == "number" then
Projectile.Size *= sizecoefficent
end
Projectile.OriginalSize = Projectile.Size
Projectile.Origin = origin
Projectile.Velocity = velocity
Projectile.Acceleration = acceleration and acceleration or Vector3.zero
Projectile.Player = player
Projectile.Position = (origin.Position - (origin.LookVector * velocity.Magnitude * 1/60))
Projectile.Duration = duration
Projectile.Params = params
Projectile.Time = 0
Projectile.OnHitDestruct = destructionbool
Projectile.CFrame = CFrame.new()
Projectile.Damage = damage
Projectile.OnHit = OnHit
Projectile.Hit = {}
Projectile.ExplosionParams = explosion
Projectile.HitInfo = hitinfo
--Projectile.Model = Instance.new("Part")
--Projectile.Model.CanCollide = false
--Projectile.Model.CanTouch = false
--Projectile.Model.CanQuery = false
--Projectile.Model.Size = Projectile.Size
--Projectile.Model.Color = Color3.fromRGB(200, 75, 95)
--Projectile.Model.Name = "ServerBullet"
--Projectile.Model.Transparency = .85
--Projectile.Model.Material = Enum.Material.Neon
--Projectile.Model.Anchored = true
--Projectile.Model.CFrame = origin
--Projectile.Model.Parent = workspace.Garbage
GeneralEvent:FireAllClients({Name = "ClientVisuals", FunctionName = "ServerProjectileCall", FunctionArguments = {instance, hitposition, velocity.Magnitude, {origin,velocity,acceleration,sizecoefficent,duration,destructionbool, player.Character, model, Projectile.HitInfo[2], Projectile.HitInfo[3], Projectile.HitInfo[1], Projectile.ExplosionParams[8], Projectile.ExplosionParams[9], debrisbool, rotatebool, Projectile.HitInfo[4], Projectile.HitInfo[5], Projectile.HitInfo[6], Projectile.ExplosionParams[10], Projectile.ExplosionParams[11], Projectile.ExplosionParams[12]}}})
table.insert(Projectiles, Projectile)
end
function Loop(dt)
--print("Bullet Count : ",#Projectiles)
for index, Projectile in Projectiles do
--if not Projectile then continue end
if Projectile.Time >= Projectile.Duration then
Projectiles[index] = nil
Projectile = nil
continue
end
local inversespeed = (1/math.max(Projectile.Velocity.Magnitude, 0.01))
local sizecoefficient = (1 - inversespeed) ^ 2
Projectile.Time += dt
Projectile.Size = Vector3.new(Projectile.Size.X, Projectile.Size.Y, math.clamp((Projectile.Velocity * dt * sizecoefficient * 1.45).Magnitude * Projectile.OriginalSize.Z, Projectile.OriginalSize.Z, 150))
Projectile.Velocity += Projectile.Acceleration * dt
Projectile.Position += Projectile.Velocity * dt
local velocityDir = Projectile.Velocity.Unit
Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + velocityDir) * CFrame.new(0, 0, -Projectile.Size.Z / 2)
local hit_table : {Model} = HitboxModule.Projectile(Projectile.CFrame, Projectile.Size, Projectile.Params, Projectile.OnHitDestruct)
if not hit_table then continue end
for i, hit : {} in hit_table do
local damage = Projectile.Damage
local character = hit.Target
local function clearProjectile()
Projectiles[index] = nil
Projectile = nil
end
if table.find(Projectile.Hit, character) then
continue
end
table.insert(Projectile.Hit, character)
local humanoid : Humanoid = character:FindFirstChild("Humanoid")
if not humanoid then
humanoid = character.Parent:FindFirstChild("Humanoid")
character = character.Parent
end
if not humanoid then
if i == #hit_table and Projectile.OnHitDestruct then
Projectile.OnHit(Projectile, "Map", nil, 3, hit.ContactPoint)
clearProjectile()
end
continue
end
Damage(Projectile.Player, character, humanoid, damage, false)
Projectile.OnHit(Projectile, "Player", character, 3, hit.ContactPoint)
if i == #hit_table and Projectile.OnHitDestruct then
clearProjectile()
end
end
--print(Projectile.Hit[1], index, Projectile.Hit)
end
ProjectileModule.Projectile makes the bullet data and the Loop function changes the size, position and velocity of each projectile