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

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

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

✓ 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

0

HI,I will try this tonight as it is 8 am for me

0

Alright, make sure to accept this answer if it works :)

0

thanks done it worked!

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