Ive been having this strange issue with my tween only running if I dont have any wait()'s, then it runs exactly 12 times 100% of the time
here is an example of it not working:
local PrimaryPartDestination = Vector3.new(x, y, z + 2.5)
local clicked = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if not clicked then
clicked = true
for i,Part in pairs(Model:GetChildren()) do
local Tween = TweenService:Create(Part,Info,{CFrame = CFrame.new((Part.Position-Model.PrimaryPart.Position)+PrimaryPartDestination)})
Tween:Play()
playquit:Play()
print("test")
repeat task.wait() until not playquit.IsPlaying
print("anim done")
local bomb = Instance.new("Explosion")
bomb.Position = Vector3.new(dumx + 20, dumy, dumz + 10.5)
bomb.BlastRadius = 2
bomb.Parent = workspace
task.wait()
script.Parent.Parent.Parent.DummyTest:Destroy()
clicked = false
end
end
end)
and here is it working
local PrimaryPartDestination = Vector3.new(x, y, z + 2.5)
local clicked = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if not clicked then
clicked = true
for i,Part in pairs(Model:GetChildren()) do
local Tween = TweenService:Create(Part,Info,{CFrame = CFrame.new((Part.Position-Model.PrimaryPart.Position)+PrimaryPartDestination)})
Tween:Play()
playquit:Play()
print("test")
--repeat task.wait() until not playquit.IsPlaying
--print("anim done")
--local bomb = Instance.new("Explosion")
--bomb.Position = Vector3.new(dumx + 20, dumy, dumz + 10.5)
--bomb.BlastRadius = 2
--bomb.Parent = workspace
--task.wait()
--script.Parent.Parent.Parent.DummyTest:Destroy()
--clicked = false
end
end
end)
if I completely get rid of the wait it cant run 12 times and doesn’t run the tween. Ive been struggling with this for almost a day it would be great if anyone can point out my mistake. Thanks
ive run other tests with waits and the same thing happened
all of my other tween info is above this thats not the issue