Hey everyone! So right now I am trying to make a naval artillery barrage, and when I go to add the 2 vector 3’s that need to be added to get a new position, it throws the error unable to perform arithmetic (add) on vector3 and number
. I’ve tried coroutines and I don’t know if I’m doing this wrong or what.
local mortar = coroutine.wrap(function(Player, Goal, number)
if Cooldowns[Player.Name] == nil then
Cooldowns[Player.Name] = 0
end
if tick() - Cooldowns[Player.Name] > 30 then
if Player.Character:FindFirstChild("Naval Barrage") then
Cooldowns[Player.Name] = tick()
local Mortar = workspace["202 - ".. number]
local tInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
local newTween = game:GetService("TweenService"):Create(Mortar.PrimaryPart, tInfo, {Orientation = Vector3.new(-75,0,0)})
newTween:Play()
newTween.Completed:Wait()
local Origin = workspace["202 - "..number].FirePart
Mortar.FirePart.Fire:Play()
Mortar.FirePart.Smoke:Emit(25)
Mortar.FirePart.Flash.Enabled = true
wait(.1)
Mortar.FirePart.Flash.Enabled = false
local NGoal = Goal + RandomPointInCircle((Origin.Position-Goal).Magnitude)
local Final = Projectile(Origin.Position,NGoal,Player)
local Object = game.ServerStorage.BarrageFX:Clone()
Object.Parent = workspace.MortarProjectiles
Object.CFrame = CFrame.new(Final)
Object.Smoke:Emit(7050)
Object.Smoke2:Emit(750)
Object.Debris:Emit(5000)
Object.Debris2:Emit(5000)
Object.Explosion:Play()
game.Debris:AddItem(Object,15)
Explode(Object,Player)
wait(1)
local FinalTween = game:GetService("TweenService"):Create(Mortar.PrimaryPart, tInfo, {Orientation = Vector3.new(0,0,0)})
FinalTween:Play()
FinalTween.Completed:Wait()
end
end
end)
game.ReplicatedStorage.FireBarrage0.OnServerEvent:Connect(function(Player,Goal, num)
mortar(Player, Goal, num)
end)