How to make a fading gui appears and disappears when u touch a part?

Hi everyone. So im working on a script that when you touch a button, a door opens and then a neon part in replicated storage comes on the position of the door and when u touch that neon part, it teleports you to a place. What i want to add is, a fading gui appears while you teleporting to the place. I tried 2 ways; first was doing it with for loop, but it worked with problem. Second one was doing with tweenService and it didnt even do anything. Here s the script (its in starterGui, i want it to only do on client);

local tweenserv = game:GetService("TweenService")

	game.ReplicatedStorage.TpRedDoor.Parent = game.Workspace
	game.Workspace.RedDoorButton.Position = game.Workspace.RedDoorButton.Position -, 0, 0)
	game.Workspace.RedDoorButton.Script.Enabled = false
	local redDoor = game.Workspace.RedDoor
	task.spawn(function() -- this is multi threading allows you to run code concurrently, well i think roblox mimics it or thats python? idk, but anyways we dont want the stuff below it to wait right? so we make it run concurrent with them by giving it a new thread to run off of
		for i,v in pairs(redDoor:GetDescendants()) do
			if v:IsA("BasePart") then -- we can check what class the Parent of the part that touched this part is then then
					tweenserv:Create(v,, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
			if v:IsA("BasePart") then-- basepart class is a superclass it refers to every part class, classes have a superclass that they are a child of, meshparts any type of parts are baseparts just like how module scripts, scripts and localscripts are all under the superclass BaseScript
					tweenserv:Create(v,, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
		local tpRedDoor = game.Workspace:FindFirstChild("TpRedDoor") -- tip if your not doing a check use [""] for faster index or .name but it doesnt matter
		local tweenserv = game:GetService("TweenService")

		tpRedDoor.Touched:Connect(function(hit) -- good
			if hit.Parent:FindFirstChild("Humanoid") then -- good also if this is only for players it will work for ai to if their humanoid is named humanoid
        --[[for i = 1,100 do 
            if script.Parent.Frame.BackgroundTransparency == 0 then
            script.Parent.Frame.BackgroundTransparency -= 0.05
        for i = 1,100 do
            if script.Parent.Frame.BackgroundTransparency == 1 then
            script.Parent.Frame.BackgroundTransparency += 0.05
				tweenserv:Create(script.Parent.Frame,[[TIME]], Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0--[[repeat count]], true--[[whether or not the tween reverses]]), {BackgroundTransparency = 1}--[[properties to change]]):Play()
				tpRedDoor.BrickColor ="Cocoa")

And as you see i gave the for loop ver in square brackets too. So how can i make the fading gui here? Thanks to anyone can help!

hey i got to understand a bit more, does any error appear in output, or anything at all?
if anything does appear please link it so i can take a look

This is one of my scripts used for sleeping in a bed. Should work great for what you’re looking to do.
It fades to black then fade back from black… A RemoveEvent along with 2 scripts (one to call it).
Script names don’t matter… I used Sleeper for the local script.

– a Local Script (in StarterGui)

local Players = game:GetService("Players")
local player = Players.LocalPlayer
	local color ="ColorCorrectionEffect") color.Parent = game.Lighting color.Enabled = true
	local tweenInfo =,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,true,0)
	local tween = game:GetService("TweenService"):Create(color, tweenInfo, {Brightness = -1})
	tween:Play() task.wait(3) tween:Pause() task.wait(3) tween:Play() task.wait(1)
	tween.Completed:Wait() task.wait(0.33) color:Destroy() task.wait(0.33)	

– a Non-Local Script (anyplace)

local player = game.Players:FindFirstChild(character.Name)

And of course in (ReplicatedStorage)
RemoveEvent named ScreenChange.

Like I said, for sleeping so you may want to have it not wait as long in the black.
Or maybe go white… If you shorten up the black wait time it should look perfect.

Thanks this is what i looked for

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.