I am trying to create a black screen that fades onto the players screen when they touch the teleport block and then once they have been teleported for the black screen to fade off the players screen
I don’t know if I should implement it into this script or do it separate but this is the script that teleports the player when they touch the teleporter
The main issue is that i dont know how to define the player from them touching the block
I have tried looking about on the dev forum but cant really find anything that related to this specifically
local fade = -- Frame name
local function FadeIn()
fade.Visible = true -- (you can also just set the BackgroundTransparency to 1 so you don't have to make the frame visible)
for i = 1, 0, -0.03 do
fade.BackgroundTransparency = i
wait(.01)
end
end
local function FadeOut()
for i = 1, 0, 0.03 do
fade.BackgroundTransparency = i
wait(.01)
end
end
EnterTeleportationPart.Touched:Connect(FadeIn)
EnterTeleportationPart.TouchEnded:Connect(FadeOut)
Go into StarterGui, add a ScreenGui (name it if you want), put in a frame and a local script and paste the script there (change variables if needed)
Size the frame to 1, 0, 1, 0
Make the BackgroundColor Black
Set BackgroundTransparency to 1
And if you notice a weird thing if the frame is not fully on screen and cuts of at the top, go to the ScreenGui and IgnoreGuilnset (this only happens in game)
also for the localscript make a variable for the part that gets touched, I forgot that
You could use tween service to tween the transparency of a black frame like this:
local frame = game.StarterGui.Frame -- Enter the name of the frame
local door = script.Parent
local tweenService = game:GetService("TweenService") -- tweenService
local appearInfo = tweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false) -- TweenInfo
local disappearInfo = tweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false)
local appear = tweenService:Create(frame, appearInfo, {Transparency = 0})
local disappear = tweenService:Create(frame, disappearInfo, {Transparency = 1}
door.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
appear:Play()
wait(2)
disappear:Play()
end
end)
door = script.Parent
door.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local screen = game.ServerStorage.Gui.Fade1:Clone()
screen.Parent = player.PlayerGui
for i = 1, 0, -0.3 do
screen.Fade.BackgroundTransparency = i
wait(.01)
end
wait(.5)
local plrCFrame = hit.Parent.HumanoidRootPart.CFrame
hit.Parent.HumanoidRootPart.CFrame = workspace.teleport.door1.CFrame + workspace.teleport.door1.CFrame.LookVector * 5
for i = 0, 0, 0.3 do
screen.Fade.BackgroundTransparency = i
wait(.01)
screen:Destroy()
end
end
end)
I managed to do it by doing this, not sure if it would’ve been easier another way or whatever but this is what I found to work