local function Fire(barrelAttachment)
local bar = barrelAttachment
local pos = (bar.CFrame + bar.CFrame.LookVector * BULLET_MAXDIST).Position
local inter = (barrelAttachment.WorldPosition - pos).Magnitude
local dir
local modifiedBulletSpeed
local spread = inter - math.random(MIN_BULLET_SPREAD_ANGLE, MAX_BULLET_SPREAD_ANGLE)
local wallOrigin = barrelAttachment.WorldPosition
-- error happens here -- local wallDirection = ((inter + spread) - wallOrigin).Unit * BULLET_MAXDIST -- error happens here, has nothing to do with unit * bullet_maxdist
local wallRay = workspace:Raycast(wallOrigin, wallDirection, CastParams)
if wallRay then
local origin = barrelAttachment.Position
local direction = (wallRay.Position - origin).Unit * (wallRay.Position - origin).Magnitude
dir = direction
modifiedBulletSpeed = (dir * BULLET_SPEED)
else
local origin = barrelAttachment.Position
local direction = (spread - origin).Unit * BULLET_MAXDIST
dir = direction
end
local cast = Caster:Fire(barrelAttachment.WorldPosition, dir, modifiedBulletSpeed)
end
try vector3.new(inter) + vector3.new(spread)
same error
character limitttttt
can I have the whole script to try to debug it
why do you need it literally everything is right there
when I copy and paste the script some of the variables are unknown and and I need the variables
for i,v in pairs(Handle:GetChildren()) do
if v.Name ~= 'GunFirePoint' then continue end
Fire(v)
character limit
try vector3.new(inter + spread)
doesnt work
character limiteeee
swapped attachments for parts, worked awesomely.