function onTouch(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
screengui = Instance.new("ScreenGui", player.PlayerGui)
frame = Instance.new("Frame", screengui)
frame.Size = UDim2.new(1, 0, 1, 0)
frame.BackgroundColor3 = Color3.new(255, 255, 255)
frame.BackgroundTransparency = 1
for i = 1, 10 do
frame.BackgroundTransparency = frame.BackgroundTransparency - 0.1
wait()
end
hit.Parent.Torso.CFrame = workspace.BedSpawn.CFrame
wait(0.5)
for i = 1, 10 do
frame.BackgroundTransparency = frame.BackgroundTransparency + 0.1
wait()
end
screengui:Destroy()
end
end
script.Parent.Touched:connect(onTouch)
This script makes the screen flash when a player hits an object and teleports the player to another location, then fades out. The problem is, when the gui fades out and hits around 0.8 transparency, it just stops. The gui doesn't get destroyed. How come?

2 comments
It works! Thanks!
You're welcome. Did you understand what I said?