Hey, I’ve just been hit with a sudden desire to make a Popup Coin Collection sort of thing - however, there seems to be a HUGE undesired delay between touching the part and the UI appearing; could y’all help me figure out why please?
https://gyazo.com/e0d38dedb5696e1f0a5c12d4bfef1dce.gif
local TweenService = game:GetService("TweenService")
function Touched(Hit)
if game:GetService("Players"):FindFirstChild(Hit.Parent.Name) ~= nil then
local Player = game:GetService("Players")[Hit.Parent.Name]
local Ui = game:GetService("ReplicatedStorage"):FindFirstChild("AddCoinUi"):Clone()
Ui.Parent = Player.PlayerGui.ScreenGui.Frame
local Position1 = math.random(140,920)
local Position2 = math.random(109, 403)
Ui.Position = UDim2.new(0,Position1,0,Position2)
local Tween1 = TweenService:Create(Ui, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 1), {["ImageTransparency"] = 0})
local Tween2 = TweenService:Create(Ui.TextLabel, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 1), {["TextTransparency"] = 0})
Tween1:Play()
Tween2:Play()
wait(0.6)
Tween1 = TweenService:Create(Ui, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 1), {["ImageTransparency"] = 1})
Tween2 = TweenService:Create(Ui.TextLabel, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 1), {["TextTransparency"] = 1})
Tween1:Play()
Tween2:Play()
delay(1.2, function()
Tween1:Destroy()
Tween2:Destroy()
Ui:Destroy()
end)
end
end
script.Parent.Touched:Connect(Touched)
To get that gif to actually work I had to increase the “wait(0.6)” to “wait(10)” and the “delay(1.2)” to “delay(12)”.
