Trying to make this align to the raycast normal… It’s a ground-impact effect script. The reason why I want it to align to the normal is bc sometimes the player will be tossed into a wall really hard, rather than always the ground.
function(CF, Mod, Normal)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Include
params.FilterDescendantsInstances = {workspace.Map.Map}
for i = 1, (20 * Mod)/10 do
local segments = Random.new():NextInteger(7,13)
for i2 = 0, segments - 1 do
local potCf = CF * CFrame.Angles(0,math.rad(360/segments) * i2, 0) * CFrame.new(0,0, (i * -(20 * Mod)/3) - 5)
local result = workspace:Raycast(potCf.Position + Vector3.new(0,3,0), Vector3.new(0,-10,0), params)
if result then
local hb = Instance.new("Part", workspace.Fx)
hb.Anchored = true
hb.CanCollide = false
hb.Transparency = result.Instance.Transparency
hb.Color = result.Instance.Color
hb.Material = result.Material
hb.Name = "hb"
hb.CanQuery = false
hb.Size = Vector3.new(math.random(8,14) * 10 * Mod/segments,math.random(5,6),math.random(5,10))
hb.CFrame = potCf
hb.Position = result.Position - Vector3.new(0,5,0)
hb.CFrame *= CFrame.Angles(math.rad(math.random(10,45)),0,0)
ts:Create(
hb,
TweenInfo.new(.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
{Position = hb.Position + Vector3.new(0,3,0) }
):Play()
task.delay(.3,function()
ts:Create(
hb,
TweenInfo.new(.6, Enum.EasingStyle.Back, Enum.EasingDirection.In),
{Position = hb.Position - Vector3.new(0,6 * Mod,0)}
):Play()
end)
game.Debris:AddItem(hb, 1.5)
end
end
wait()
end
end,
Sorry if this is a bit much… I am not very good with CFrame things… Please help me CFrame wizards…