Hello everyone, I can’t change how to add a delay to my script. The delay should be after all gems are spawned.
local gui = script.Parent
local Gems = gui.ImageLabel
local GemsPosition = gui.GemsLable
local touchedPart = game.Workspace:WaitForChild("Part")
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)
local false1 = false
local goal = {
Position = GemsPosition.Position
}
touchedPart.Touched:Connect(function(plr)
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid and false1 == false then
false1 = true
for i = 1, 10 do
local randomX = math.random(35, 65) / 100
local randomY = math.random(35, 65) / 100
local gemsClone = Gems:Clone()
gemsClone.Parent = gui
gemsClone.Position = UDim2.new(randomX, 0, randomY, 0)
local Tween = tweenService:Create(gemsClone, tweenInfo, goal)
Tween:Play()
end
wait(3)
false1 = false
end
end)
local gui = script.Parent
local Gems = gui.ImageLabel
local GemsPosition = gui.GemsLable
local touchedPart = game.Workspace:WaitForChild("Part")
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)
local false1 = false
local goal = {
Position = GemsPosition.Position
}
touchedPart.Touched:Connect(function(plr)
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid and false1 == false then
false1 = true
TweenTable = {}
for i = 1, 10 do
local randomX = math.random(35, 65) / 100
local randomY = math.random(35, 65) / 100
local gemsClone = Gems:Clone()
gemsClone.Parent = gui
gemsClone.Position = UDim2.new(randomX, 0, randomY, 0)
local Tween = tweenService:Create(gemsClone, tweenInfo, goal)
table.Insert(TweenTable, Tween)
end
wait(1)
for i, v in pairs(TweenTable) do
V:Play()
end
wait(2)
false1 = false
end
end)
local gui = script.Parent
local Gems = gui.ImageLabel
local GemsPosition = gui.GemsLable
local touchedPart = game.Workspace:WaitForChild("part1")
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)
local false1 = false
local goal = {
Position = GemsPosition.Position
}
touchedPart.Touched:Connect(function(plr)
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid and false1 == false then
false1 = true
local TweenTable = {}
for i = 1, 10 do
local randomX = math.random(35, 65) / 100
local randomY = math.random(35, 65) / 100
local gemsClone = Gems:Clone()
gemsClone.Parent = gui
gemsClone.Position = UDim2.new(randomX, 0, randomY, 0)
local Tween = tweenService:Create(gemsClone, tweenInfo, goal)
table.Insert(TweenTable, Tween)
end
wait(1)
for i, v in pairs(TweenTable) do
v:Play()
end
wait(2)
false1 = false
end
end)