Hello everyone! This is my first time posting, so the post might be a bit confusing!
So here, I have a module script, that I use for a simple ground break type of effect, and it works perfectly fine, until it doesn’t…What I want, is to pop the created parts up(since the ground is broken you know…), and then wait some time, before popping it back to the initial position…and the pop up tween works fine, but the other one, the one where the parts have to pop back to the initial position doesn’t…I would love to know why…it doesn’t even print(‘Played’).
local module = {}
local ts = game:GetService('TweenService')
function module.groundBreakVFX(hrp, circleSize, requiredParts, requiredAngleAdd)
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {workspace.DebrisFolder}
rayParams.FilterType = Enum.RaycastFilterType.Exclude
local angle = 0
for i = 1, requiredParts do
local size = math.random(2, 3)
local part = Instance.new('Part')
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(1, 1, 1)
part.CFrame = hrp.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(angle), 0) * CFrame.new(circleSize, 5, 0)
game.Debris:AddItem(part, 5)
local RayCast = workspace:Raycast(part.CFrame.p, part.CFrame.UpVector * -100, rayParams)
if RayCast then
part.Position = RayCast.Position + Vector3.new(0, -5, 0)
part.Size = Vector3.new(size, size, size)
part.Material = RayCast.Instance.Material
part.Color = RayCast.Instance.Color
part.Orientation = Vector3.new(math.random(-180, 180), math.random(-180, 180), math.random(-180, 180))
part.Parent = workspace.DebrisFolder
local Tween = ts:Create(part, TweenInfo.new(0.25, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut), {Position = part.Position + Vector3.new(0, 5, 0)}):Play()
else
part:Destroy()
end
angle += requiredAngleAdd
end
task.wait(2)
print("Played")
for _, part in workspace.DebrisFolder:GetChildren() do
print("Tweening part down")
local tween2 = ts:Create(part, TweenInfo.new(0.25, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out), {Position = part.Position + Vector3.new(0, -5, 0)})
tween2:Play()
end
end
return module