I have a UFO function which I’m using for my minigame, and it works, but not how I’d like it to.
The issue is, while it’s still playing the tween, it instances an explosion on the chosen tile even though its not there yet.
What I want it to do is to wait until the tween I made is completed, then instance the explosion, before moving onto the next tile.
Help?
function UFO()
local goal = {}
local ToDestroy = {}
local clone = game.ServerStorage.Disasters.UFO:Clone()
clone.Parent = workspace
for i = 1, 9, 1 do
local Tile = SelectTiles()
table.insert(ToDestroy, #ToDestroy+1,Tile)
end
for i, v in pairs(ToDestroy) do
goal.Position = v.Position + Vector3.new(0,50,0)
clone.Handle.Anchored = true
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local tween = TweenService:Create(clone.Handle, tweenInfo, goal)
tween:Play()
wait(2)
local Explosion = Instance.new("Explosion", v)
Explosion.Position = v.Position
script.Explosion:Play()
Explosion:Destroy()
v:Destroy()
end
delay(1, function()
clone:Destroy()
end)
end