Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
Apologies, I've edited the script. It should now work. crookedsuper 56 — 6y
Ad

Answer this question