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

0 How to make a screen go black and teleport the players to a different place?

Asked by 2 years ago

Hello,i am making a story game and after my first challenge,I want to make the screen go black after the timer script ends (Here is the timer script):


local player = game.Players.LocalPlayer local TimerEvent = game.ReplicatedStorage.TimerEvent local ScreenGui = player.PlayerGui.ScreenGui local stopTimer = false TimerEvent.OnClientEvent:Connect(function(timer) ScreenGui.TimerFrame.TextLabel.Text = timer ScreenGui.TimerFrame.TextLabel.Visible = true wait(1) repeat timer = timer - 1 ScreenGui.TimerFrame.TextLabel.Text = timer wait(1) until timer <= 0 or stopTimer == true ScreenGui.TimerFrame.TextLabel.Visible = false stopTimer = false end)

I want the players to be teleported outside for the next one

If you need me to be more specific the tell me

Many thanks

BIgkiddo27

1 answer

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

To make the screen go black, you will simply need to use a GUI with a black/dark frame in it, which you Tween the transparency of, combined with simply setting the player's CFrame (Position) to your desired location.

I am assuming you could put the frame in your already existing GUI referenced in your code, and will reference it as "Blackout"

One thing I would advice changing, referencing your GUI via the player like that is risky. If you have another GUI called "ScreenGui" in your player, you may get the wrong one. Instead, put the script inside of the GUI and do: local ScreenGui = script.Parent

Otherwise, simply put the Tween at the end of the function, when it's fully black, change the player position, then make the background transparent again. Something like this:

local player = game.Players.LocalPlayer
local TimerEvent = game.ReplicatedStorage.TimerEvent
local ScreenGui = script.Parent
local TeleportToPart = workspace.TeleportBrick1
local Tween = game:GetService('TweenService')

local stopTimer = false

TimerEvent.OnClientEvent:Connect(function(timer)
    ScreenGui.TimerFrame.TextLabel.Text = timer
    ScreenGui.TimerFrame.TextLabel.Visible = true
    wait(1)
    repeat
        timer = timer - 1
        ScreenGui.TimerFrame.TextLabel.Text = timer
        wait(1)
    until
    timer <= 0 or stopTimer == true
    ScreenGui.TimerFrame.TextLabel.Visible = false  
    stopTimer = false

    Tween:Create(ScreenGui.Blackout, TweenInfo.new(1), {BackgroundTransparency = 0;}):Play()
    wait(1.1)
    player.Character.HumanoidRootPart.CFrame = TeleportToPart.CFrame
    wait(.4)
    Tween:Create(ScreenGui.Blackout, TweenInfo.new(1), {BackgroundTransparency = 1;}):Play()
    wait(1)
end)

Hope this helps :)

0
HI,I will try this tonight as it is 8 am for me bigkiddo27 6 — 2y
0
Alright, make sure to accept this answer if it works :) NinjaMandalorian 252 — 2y
0
thanks done it worked! bigkiddo27 6 — 2y
Ad

Answer this question