Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script is supposed to fade out and teleport, instead doesn't fade out and only teleports?

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 answer

✓ Accepted answer

This is due to the fact you are editing the Starter Gui rather than the GUI that the player actually has. After looking, the script provided below should work, if not feel free to contact me.

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()
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 1
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.9
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.8
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.7
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.6
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.5
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.4
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.3
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.2
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0.1
    wait(0.1)
    player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0
    TeleportService:Teleport(gameID)
end)

1 comment

0

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

This discussion is preserved as it was. New answers, comments, and votes are closed.