So I'm making a script that basically when you die your screen fades to black and you get teleported. I made a localscript for this and it worked, however, all it is doing is teleporting. How could I fix this?
local TeleportService = game:GetService("TeleportService")
local gameID = 2094965912
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
character:WaitForChild("Humanoid").Died:Connect(function()
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 1
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.9
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.8
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.7
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.6
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.5
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.4
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.3
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.2
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0.1
wait(0.1)
game.StarterGui.ScreenGui.Frame.BackgroundTransparency = 0
TeleportService:Teleport(gameID)
end)

1 comment
Apologies, I've edited the script. It should now work.