I'm trying to make a script where if you click on a door, the screen will fade to black, and the player will be teleported to the set coordinates, to the screen fading back up again. For some reason, it only teleports me a second after clicking on it, without any of the fading or anything. Just need help with figuring this one out please.
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local char = player.Character
local gui = game.StarterGui.ScreenGui.FrameDark
gui.BackgroundTransparency = 0.9
wait(0.1)
gui.BackgroundTransparency = 0.8
wait(0.1)
gui.BackgroundTransparency = 0.7
wait(0.1)
gui.BackgroundTransparency = 0.6
wait(0.1)
gui.BackgroundTransparency = 0.5
wait(0.1)
gui.BackgroundTransparency = 0.4
wait(0.1)
gui.BackgroundTransparency = 0.3
wait(0.1)
gui.BackgroundTransparency = 0.2
wait(0.1)
gui.BackgroundTransparency = 0.1
wait(0.1)
gui.BackgroundTransparency = 0
wait(0.1)
char.HumanoidRootPart.CFrame = CFrame.new(-10.9, 1.75, 50.5)
wait(0.1)
gui.BackgroundTransparency = 0
wait(0.1)
gui.BackgroundTransparency = 0.1
wait(0.1)
gui.BackgroundTransparency = 0.2
wait(0.1)
gui.BackgroundTransparency = 0.3
wait(0.1)
gui.BackgroundTransparency = 0.4
wait(0.1)
gui.BackgroundTransparency = 0.5
wait(0.1)
gui.BackgroundTransparency = 0.6
wait(0.1)
gui.BackgroundTransparency = 0.7
wait(0.1)
gui.BackgroundTransparency = 0.8
wait(0.1)
gui.BackgroundTransparency = 0.9
wait(0.1)
gui.BackgroundTransparency = 1
wait(0.1)
end)
(Also, any tips to shorten this script would be greatly appreciated)

1 comment
-1 for using misleading identifiers (char points to the player, NOT the character), for going back to game.Players to find the player, when you can use the variable directly, for not explaining, and for messy code in general. Where are your indents?