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

How do you make a cutscene teleporter?

Asked by 2 years ago

I want to make a teleporter where when you step on it, it teleports you to a certain location in the map, but I want the screen to go dark when you step on the teleporter and then slowly become brighter and then back to normal as you arrive at the teleported area, kinda like a cutscene, any idea how I could make that possible? Thanks!

1 answer

Log in to vote
0
Answered by
15BQT 15
2 years ago

First off, make two parts inside of workspace, and name them Pad1 and Pad2

Second, Insert a script into Pad1

Third, insert a bool value into StarterCharacterScripts and name it "CurrentlyTeleporting"

Fourth, insert a Gui into StarterGui and Insert a frame - Make sure it fills the screen, its BackgroundColor is 0,0,0 and its Background transparency is 1

Fifth, Insert a RemoteEvent into StarterStorage and name it Transition Event

Here's what your Script inside Pad1 should look like.

-- // Setup // --
-- Make sure to insert a bool value into StarterCharacterScripts and name it "CurrentlyTeleporting" or something like that.
-- Insert a Gui into StarterGui and name it TransitionGui. Then, Insert a frame - Make sure it fills the screen, its BackgroundColor is black and its Background transparency is 1
-- Insert a RemoteEvent into StarterStorage and name it Transition Event
-- Insert a local script inside StarterPlayerScripts.

local Pad = game.Workspace.Pad2 -- The part we want to teleport to.

script.Parent.Touched:Connect(function(hit) -- If the part is touched
    local Player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Get the player

    if Player then -- If the player exists then
        local CurrentlyTeleporting = Player.Character:FindFirstChild("CurrentlyTeleporting") -- Get the bool value (Currently teleporting)
        if not CurrentlyTeleporting then return end

        if not CurrentlyTeleporting.Value then
            game:GetService("ReplicatedStorage").TransitionEvent:FireAllClients() -- Get the Transition Event

            CurrentlyTeleporting.Value = true -- Change the value to true
            wait(2) -- Wait for the screen to turn black
            Player.Character.HumanoidRootPart.CFrame = Pad.CFrame + Vector3.new(0,5,0) -- Teleport the player to the other pad
            wait(3) -- How much time has to pass before the player can teleport again
            CurrentlyTeleporting.Value = false -- Set the value to false
        end
    end
end)

After you've made a local script inside StarterPlayerScript, put this code inside of it.

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait() -- Get the player
local TweenService = game:GetService("TweenService")
local RemoteEvent = game.ReplicatedStorage.TransitionEvent -- The Transition event
local Frame = Player.PlayerGui:WaitForChild("TransitionGui").Frame -- The transition frame

RemoteEvent.OnClientEvent:Connect(function() -- Do this when the event is fired
    local Info = TweenInfo.new(2)
    local Visible = {}
    local Invisible = {}

    Visible.BackgroundTransparency = 0
    Invisible.BackgroundTransparency = 1

    local TweenVisible = TweenService:Create(Frame,Info,Visible)
    local TweenInvisible = TweenService:Create(Frame,Info,Invisible)

    TweenVisible:Play() -- Start transition
    -- This is optional but you can set the player's walkspeed to 0 while the transition is playing
    Character:WaitForChild("Humanoid").WalkSpeed = 0
    wait(4)
    Character:WaitForChild("Humanoid").WalkSpeed = 12
    TweenInvisible:Play() -- Stop transition
end)

And you should be done! If you also want to teleport the player when they step on Pad2, copy the same script from Pad1 and place it into Pad2 but replace "Pad1" with "Pad2". Let me know if you have any questions!

0
Thank you so so much! Ghostinee 27 — 2y
Ad

Answer this question