Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make your screen fade when you touch a teleport brick?

Asked by 7 years ago

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! :)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.

0
Don't make the size {0, 10000} {0, 10000}, just make it {1, 0} {1, 0} for convenience. marioblast1244 113 — 7y
0
That works too. But I always use 1000. wilsonsilva007 373 — 7y
0
Hello wilsonsilva007, thank you very much for your answer. I have tried what you've told me to above, and tested it out, but it doesn't do anything. FilteringEnabled is not on, made sure of that first. When I view the Output when I walk into the teleporter, it says 'Argument 1 missing or nil' Do you have any ideas why? Harrydamastr 35 — 7y
0
I will test it in studio and I'll fix everything that's wrong as soon as I can. Don't worry. wilsonsilva007 373 — 7y
0
Okay, thank you. Sorry for the late reply Harrydamastr 35 — 6y
Ad

Answer this question