So I have a teleport script, and when a player touches it, it (of course) teleports them to the CFrame I put in it. I want it, so when a player touches the brick, it fades to black and then teleports you, and then fades back. I am not a good scripter at all, but I do know quite a lot of things, just not this.
Here's the teleport script I've been using:
script.parent.touched:connect(function(hit) if hit.Parent:findFirstChild('Humanoid')then hit.Parent.Torso.CFrame = CFrame.new(-502, -16.5, 153) end end)
Thanks! :)
So first of all you need to create a GUI in the starter pack. Name that GUI "ScreenEffect" and inside it incert a frame. Name that frame "Black" and size it about... {0,1000,0,1000} and make it's colour "Really black".
Great! Now we have our effect created. Now we just want to make it work.
Lets make an on touch effect
script.Parent.Touched:connect(function(hit) --Parent and Touched are capitalized. if hit.Parent:findFirstChild('Humanoid')then hit.Parent.Torso.CFrame = CFrame.new(-502, -16.5, 153) --Since it's torso player must be using R6. end end)
Now we'll create a function that will make that effect fade!
script.Parent.Touched:connect(function(hit) --Parent and Touched are capitalized. game.Players:WaitForChild(playername).PlayerGui.ScreenEffect.Black.Visible = true for i = 1 ,10 do local playername = hit.Parent.Name game.Players:WaitForChild(playername).PlayerGui.ScreenEffect.Black.BackgroundTransparency = game.Players:WaitForChild(playername).PlayerGui.ScreenEffect.Black.BackgroundTransparency + 0.100 --Fade slowly --BackgroundTransparency must be on 0 to work. wait(.5) end if hit.Parent:findFirstChild('Humanoid')then hit.Parent.Torso.CFrame = CFrame.new(-502, -16.5, 153) --Since it's torso player must be using R6. end end) wait(5) for i = 1 ,10 do local playername = hit.Parent.Name game.Players:WaitForChild(playername).PlayerGui.ScreenEffect.Black.BackgroundTransparency = game.Players:WaitForChild(playername).PlayerGui.ScreenEffect.Black.BackgroundTransparency - 0.100 --Fade slowly --BackgroundTransparency should be on 1. wait(.5) end wait(3) game.Players:WaitForChild(playername).PlayerGui.ScreenEffect.Black.Visible = false
Note: The "Black" frame transparency must be on 0 when editing. Don't worry, must be invisible to fade, obviously.
I didn't test this on studio so if there's any error comment and I'll try to fix it.