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)
script.Parent.ClickDetector.MouseClick:connect(function(char) local plr = game.Players:FindFirstChild(char.Name) for i = 1,0,-0.1 do wait() plr.PlayerGui.ScreenGui.FrameDark.Transparency = i end end)