Hello! I am currently making an A-10 Warthog airstrike in roblox, and I am having troubles with setting the explosions position. I’m using raycasts from the plane to the target to put the explosions there. However, instead of being scattered around-ish but generally in one main area, its completely scattering around. Going up when it shouldn’t, moving 100 studs away, overall its just very weird.
What I want it to look like:
What it actually looks like:
Here is the code in question:
ray_params.FilterType = Enum.RaycastFilterType.Blacklist
ray_params.FilterDescendantsInstances = {jet, jet.PrimaryPart}
task.wait(1.45)
for i = 1, 56 do
local raycast_result = workspace:Raycast(jet.PrimaryPart.Position, (target.Position - jet.PrimaryPart.Position), ray_params)
if raycast_result then
local instance = raycast_result.Instance
local model = instance:FindFirstAncestorOfClass("Model")
--if the ray hit anything
if (model) or (not model) then
local hit_pos = raycast_result.Position
local hit_norm = raycast_result.Normal
--explosion
local explosion = Instance.new("Explosion", workspace)
DEBRIS:AddItem(explosion, 4)
explosion.BlastPressure = 1000000
explosion.BlastRadius = 1000
print(instance)
explosion.ExplosionType = Enum.ExplosionType.Craters
local offset = hit_norm + Vector3.new(math.random(-50, 50), 0, math.random(-50, 50))
explosion.Position = hit_pos + offset
--destroying parts
explosion.Hit:Connect(function(part)
part.Anchored = false
end)
end
end
task.wait(.025)
end
Any help will be appreciated