✓ Accepted answer
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 :)
3 comments
HI,I will try this tonight as it is 8 am for me
Alright, make sure to accept this answer if it works :)
thanks done it worked!