How To Make An Elevator Game In Roblox Studio (Part 2)

Поділитися
Вставка
  • Опубліковано 20 січ 2025

КОМЕНТАРІ • 70

  • @unionedspider
    @unionedspider  6 місяців тому +2

    After line 8 in the OnPlayerAdded script I forgot to add this line of code:
    activelyPlaying.Parent = valuesFolder
    If you need help getting your elevator game to work, or you wanna join my community I have a discord server.
    discord.gg/RRMurrCaUy

  • @pippady1
    @pippady1 6 місяців тому +1

    This is a great tutorial and is helping me make my game. Hope you continue this series.

  • @azureglitchy
    @azureglitchy 5 місяців тому +1

    this is actually such a goated tutorial dude keep making more

  • @Eevee-eo6ib
    @Eevee-eo6ib 4 місяці тому

    Thank you for making this tutorial! It's very helpful! :D

  • @noobie425
    @noobie425 3 місяці тому +5

    Sorry but i am having another issue When i try to walk into the elevator it just doesnt go it my script looks like this
    local Elevator = script.Parent.Parent.Parent
    local ElevatorTeleportPart = workspace.Elevator.TeleportPart
    local EntryTouchPart = script.Parent
    local TeleportParts = {
    Elevator.WaitingParts.WaitingPart1,
    Elevator.WaitingParts.WaitingPart2,
    Elevator.WaitingParts.WaitingPart3,
    Elevator.WaitingParts.WaitingPart4,
    Elevator.WaitingParts.WaitingPart5,
    Elevator.WaitingParts.WaitingPart6,
    }
    local ElevatorEmpty = true
    local ElevatorOpen = true
    local CountdownTime = 6
    local MainDoor = Elevator.Door.MainDoor
    local Door1 = Elevator.Door.RightDoor
    local Door2 = Elevator.Door.LeftDoor
    local TweenService = game:GetService("TweenService")
    local InitialPosition1 = Door1.Position
    local InitialPosition2 = Door2.Position
    local TargetPosition1 = InitialPosition1 + Vector3.new(0,0, -3.2)
    local TargetPosition2 = InitialPosition2 - Vector3.new(0,0, -3.2)
    local Duration = 3.3
    local EasingStyle = Enum.EasingStyle.Sine
    local EasingDirection = Enum.EasingDirection.Out
    local Tween1 = TweenService:Create(
    Door1,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = TargetPosition1}
    )
    local Tween2 = TweenService:Create(
    Door2,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = TargetPosition2}
    )
    local TweenBack1 = TweenService:Create(
    Door1,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = InitialPosition1}
    )
    local TweenBack2 = TweenService:Create(
    Door2,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = InitialPosition2}
    )
    local function TeleportToTeleportPart(player)
    for _, part in ipairs(TeleportParts) do
    local occupied = part:FindFirstChild("Occupied")
    if not occupied then
    local playerName = Instance.new("StringValue")
    playerName.Name = "PlayerName"
    playerName.Value = player.Name
    playerName.Parent = part

    local isOccupied = Instance.new("BoolValue")
    isOccupied.Name = "Occupied"
    isOccupied.Value = true
    isOccupied.Parent = part

    local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
    if humanoid then
    player.Character:SetPrimaryPartCFrame(part.CFrame)
    end

    return true
    end
    end
    return false
    end
    local function CountdownAndTeleport()
    local CountdownText1 = script.Parent.Timer.TimerFront.Frame.TextLabel
    local CountdownText2 = script.Parent.Timer.TimerBack.Frame.TextLabel

    for sec = CountdownTime, 0, -1 do
    CountdownText1.Text = tostring(sec)
    CountdownText2.Text = tostring(sec)
    wait(1)
    end
    ElevatorOpen = false
    TweenBack1:Play()
    TweenBack2:Play()
    CountdownText1.Text = ""
    CountdownText2.Text = ""
    wait(3.6)

    for _, part in ipairs(TeleportParts) do
    local playerName = part:FindFirstChild("PlayerName")
    local isOccupied = part:FindFirstChild("Occupied")

    if playerName and isOccupied and isOccupied.Value then
    local player = game.Players:FindFirstChild(playerName.Value)

    if player then
    local Humanoid = player.Character and player.Character:FindFirstChild("Humanoid")

    if Humanoid then
    player.Character:SetPrimaryPartCFrame(ElevatorTeleportPart.CFrame)
    player.ValuesFolder.ActivelyPlaying.Value = true
    playerName:Destroy()
    isOccupied:Destroy()
    Humanoid.Walkspeed = 16
    Humanoid.JumpHeight = 7.2
    end
    end
    end
    end
    wait(2)
    Tween1:Play()
    Tween2:Play()
    wait(3.5)
    ElevatorOpen = true
    ElevatorEmpty = true
    end
    local TouchCooldown = false
    EntryTouchPart.Touched:Connect(function(hit)
    if TouchCooldown or not ElevatorOpen then
    return
    end
    TouchCooldown = true

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player and hit.Parent:FindFirstChild("Humanoid") then
    local teleported = TeleportToTeleportPart(player)
    if teleported then
    hit.Parent.Humanoid.WalkSpeed = 0
    hit.Parent.Humanoid.JumpHeight = 0

    if ElevatorEmpty then
    ElevatorEmpty = false
    coroutine.wrap(CountdownAndTeleport)()
    end
    end
    end

    wait(1)
    TouchCooldown = false
    end)
    Tween1:Play()
    Tween2:Play()

    • @G1rlPl3asBEE
      @G1rlPl3asBEE 22 дні тому

      this silly thing is you have to turn on can touch in the queue elevator main door part

    • @noobie425
      @noobie425 21 день тому

      @G1rlPl3asBEE Thanks!

  • @SFKJSC
    @SFKJSC 6 місяців тому +2

    Tutorial is great but i've got one question how do i make so floors wasn't same 2 or more times in a row?

    • @unionedspider
      @unionedspider  6 місяців тому

      @@SFKJSC The code in this video fixes that

  • @Pebble_DandyJunior
    @Pebble_DandyJunior 6 місяців тому +1

    Will you do a money that you can get for participating in a round (like 10 or 15) and a shop in where you can buy a sword (not killing sword), speed coil and jump coil? (These were just some ideas)

  • @kohlevs
    @kohlevs 6 місяців тому

    This was a great tutorial! I only had one issue with it, for some reason my songs do shuffle but my floors sadly do not, it says that waitlist is an unknown global. One suggestion I have for this series is making a tutorial for how to give players the currencies, "Floors" (number of floors the player has done,) and "Coins" (amount of coins from one floor), and saving these stats.

    • @unionedspider
      @unionedspider  6 місяців тому

      Did you define the wait list table variable?
      like this:
      local waitlist= {}
      If you did, maybe it isn't put in the correct spot in the script. It might need to be defined earlier or later on in the script

    • @kohlevs
      @kohlevs 6 місяців тому

      @@unionedspiderthanks, it worked!

  • @madot_suki
    @madot_suki 6 місяців тому +1

    Thank you! This was so helpful!!, kind of a weird request but do you know how to make a npc join the elevator?

    • @unionedspider
      @unionedspider  6 місяців тому +1

      Yeah I'll do that in the next part

    • @madot_suki
      @madot_suki 6 місяців тому

      @@unionedspider tysm ❣️❣️❣️❣️

  • @burlytech
    @burlytech Місяць тому

    instead of making a function for each floor, you can make a folder called like "mapcode" or whatever in the floor folder and put a modulescript in there, then run the code in the modulescript when the floor is loaded

    • @unionedspider
      @unionedspider  Місяць тому

      @@burlytech Yeah good point I plan to do this in the next tutorial I upload

    • @burlytech
      @burlytech Місяць тому

      @@unionedspider 👍alright

  • @noobie425
    @noobie425 3 місяці тому +3

    Hey I dont know why but When i test out the teleporting mechanic it always says :
    393 ActivelyPlaying is not a valid member of Folder "Players.Purpledroid11.ValuesFolder" - Server - Elevator Script:75 my elevator script look like this:
    -- VARIABLES --
    local MainInfo = game.ServerStorage:WaitForChild("Info")
    local CurrentFloor = MainInfo.CurrentFloor.Value
    local ServerFloorCount = MainInfo.ServerFloorCount.Value
    local Elevator = game.Workspace:WaitForChild("Elevator")
    local MainDoor = Elevator.Door.MainDoor
    local Door1 = Elevator.Door.RightDoor
    local Door2 = Elevator.Door.LeftDoor
    local TweenService = game:GetService("TweenService")
    local InitialPosition1 = Door1.Position
    local InitialPosition2 = Door2.Position
    local TargetPosition1 = InitialPosition1 + Vector3.new(0,0, -3.2)
    local TargetPosition2 = InitialPosition2 - Vector3.new(0,0, -3.2)
    local Duration = 3.3
    local EasingStyle = Enum.EasingStyle.Sine
    local EasingDirection = Enum.EasingDirection.Out
    local Tween1 = TweenService:Create(
    Door1,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = TargetPosition1}
    )
    local Tween2 = TweenService:Create(
    Door2,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = TargetPosition2}
    )
    local TweenBack1 = TweenService:Create(
    Door1,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = InitialPosition1}
    )
    local TweenBack2 = TweenService:Create(
    Door2,
    TweenInfo.new(Duration, EasingStyle, EasingDirection),
    {Position = InitialPosition2}
    )
    local Playlist = Elevator.SoundPart:GetChildren()
    local MusicWaitlist = {}
    for _, music in ipairs(Playlist) do
    table.insert(MusicWaitlist, music)
    end
    local function chooseMusic()
    local music = table.remove(MusicWaitlist, 1)
    table.insert(MusicWaitlist, music)
    return music
    end
    local function shufflePlaylist()
    for i = #MusicWaitlist, 2, -1 do
    local j = math.random(i)
    MusicWaitlist[i], MusicWaitlist[j] = MusicWaitlist[j], MusicWaitlist[i]
    end
    end
    shufflePlaylist()
    local function shuffleWaitlist()
    for i = #waitlist, 2, -1 do
    local j = math.random(i)
    waitlist[i], waitlist[j] = waitlist[j], waitlist[i]
    end
    end
    local TeleportPart = Elevator.TeleportPart
    local function TeleportBackToElevator()
    for _, player in ipairs(game.Players:GetPlayers()) do
    if player:FindFirstChild("ValuesFolder").ActivelyPlaying.Value == true then
    if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
    local CharacterPosition = player.Character.HumanoidRootPart.Position

    if (CharacterPosition - TeleportPart.Position).Magnitude > 9 then
    player.Character:SetPrimaryPartCFrame(CFrame.new(TeleportPart.Position))
    end
    end
    end
    end
    end
    --VALUES-
    floors = {"OBBYEND", "MINEFIELD", "Floodescape", "Gamerroom", "Run"}
    CountDownTime = 25
    items = {}
    waitlist = {}
    -- FLOOR SCRIPTS --
    local function FloorOBBYEND()
    local floor = game.Workspace:WaitForChild("OBBYEND")

    MainDoor.CanCollide = false

    wait(30)



    wait(30)
    TeleportBackToElevator()
    end
    local function FloorMINEFIELD()
    local floor = game.Workspace:WaitForChild("MINEFIELD")
    MainDoor.CanCollide = false
    wait(30)
    wait(30)
    TeleportBackToElevator()
    end
    local function FloorFloodescape()
    local floor = game.Workspace:WaitForChild("Floodescape")
    MainDoor.CanCollide = false
    wait(30)
    wait(30)
    TeleportBackToElevator()
    end
    local function FloorGamerroom()
    local floor = game.Workspace:WaitForChild("Gamerroom")
    MainDoor.CanCollide = false
    wait(30)
    wait(30)
    TeleportBackToElevator()
    end
    local function FloorRun()
    local floor = game.Workspace:WaitForChild("Run")
    MainDoor.CanCollide = false
    wait(30)
    wait(30)
    TeleportBackToElevator()
    end
    -- ELEVATOR SYSTEM--
    for i=1,#floors do
    local item = game.ServerStorage.Floors:FindFirstChild(floors[i])
    if item ~= nil then
    item.Parent = nil
    table.insert(items, item)
    table.insert(waitlist, item)
    else
    print("Error:", floors[i], "was not found.")
    end
    end
    function ChooseFloor()
    local NewFloor = table.remove(waitlist, 1)
    table.insert(waitlist, NewFloor)
    CurrentFloor = NewFloor
    return NewFloor
    end
    shuffleWaitlist()
    shufflePlaylist()
    while true do
    local Map = ChooseFloor():Clone()
    local music = chooseMusic()
    music:Play()


    wait(CountDownTime)

    music:Stop()

    Map.Parent = game.Workspace
    ServerFloorCount +=1

    MainDoor.Bell:Play()

    wait(0.5)

    MainDoor.Open:Play()
    Tween1:Play()
    Tween2:Play()

    if CurrentFloor.Name == "OBBYEND" then
    FloorOBBYEND()
    elseif CurrentFloor.Name == "MINEFIELD" then
    FloorMINEFIELD()
    elseif CurrentFloor.Name == "Floodescape" then
    FloorFloodescape()
    elseif CurrentFloor.Name == "Gamerroom" then
    FloorGamerroom()
    elseif CurrentFloor.Name == "Run" then
    FloorRun()
    end

    MainDoor.CanCollide = true
    TweenBack1:Play()
    TweenBack2:Play()

    wait(5)

    Map:Destroy()

    end
    and my onplayer add looks like this:
    game.Players.PlayerAdded:Connect(function(player)
    local valuesFolder = Instance.new("Folder")
    valuesFolder.Name = "ValuesFolder"
    valuesFolder.Parent = player

    local activelyPlaying = Instance.new("BoolValue")
    activelyPlaying.Name = "ActivelyPlaying"
    activelyPlaying.Value = true
    end)

    • @unionedspider
      @unionedspider  3 місяці тому

      @@noobie425 I just now noticed that I forgot to add a line of code in the video which has been causing that error so I just put the fix in the pinned comment

    • @noobie425
      @noobie425 3 місяці тому

      @@unionedspider Oh thanks it works now Thanks for the help

  • @darkgabumon
    @darkgabumon 7 місяців тому +1

    appreciate the video, I'm pretty much following the same thing, with different models and it all works perfectly better then what I tried to make before. Just a few questions, before this video I made a song system where I reference the part containing all the song ids then use GetChildren on it. After I just use math.random to randomly pick and play a song. I tried your method and it works perfectly fine as well, though I don't exactly understand the table syntax and stuff. In your opinion is it better to use the latter or is the former alright?
    I don't know if you already done these things but maybe a shop system, leaderboard system (how to make them and save them), changing lighting or camera would be really helpful. Like some floors, my idea is to make it scary, and changing the lighting would be good. And for camera work, it would be cool to make some floors have some sort of cut scene at the beginning.
    I personally think the long videos are good, I like seeing your workflow and process. It's very insightful as someone starting to code on studio. Anyways cheers boss.

    • @unionedspider
      @unionedspider  7 місяців тому +1

      For the song system I did plan on using math.random but I felt like using this shuffle mechanism because it puts all of the songs in an organized queue line and also prevents the same song from getting picked twice in a row
      In the next part I do plan on adding a shop, leaderboard (With datastorage), and lighting changes. I'll try and see if I can do anything for camera effects

  • @RehanPoil2
    @RehanPoil2 7 місяців тому +2

    Are you gonna make a part 3 or that’s all

  • @UAUAball3728
    @UAUAball3728 6 місяців тому +2

    good tutorial but theres one issue:
    sometimes this "ServerScriptService.Elevator:117: attempt to index nil with 'Clone'" error will pop up and it will stop the script from working. how do i fix that?

    • @unionedspider
      @unionedspider  6 місяців тому

      I'm not sure, I don't know what your script looks like

  • @MarioYT21
    @MarioYT21 5 місяців тому

    This tutorial is really helpful so I can make my game but I’m experiencing a problem. After adding the new code onto the script (the part where the SoundPart plays music and stops), the elevator just doesn’t open anymore. If I use the script from Part 1, it still opens.

    • @unionedspider
      @unionedspider  5 місяців тому +1

      That means there's an error, you'll have to see what shows up in the output when you test your game. It should be in red text
      The output button is in the view tab

    • @MarioYT21
      @MarioYT21 5 місяців тому

      @@unionedspiderah ok I see. It says that SoundPart is not a valid member of Folder “Workspace.Elevator”.
      I assume I need to put the SoundPart inside the Elevator folder?
      Edit: nvm I got it to work. The problem was that the objects like SoundPart and Teleport Pad weren’t in the elevator folder. I appreciate the help

    • @unionedspider
      @unionedspider  5 місяців тому +1

      @@MarioYT21 No problem nice job

  • @Jedikm
    @Jedikm 5 місяців тому

    I loved this vid part 3 would be sick!

  • @Daniel69ElGamer
    @Daniel69ElGamer 6 місяців тому

    One question:
    In the next part you will demonstrate how to make the players if is outside of the elevator, teleport again into the elvator?

    • @unionedspider
      @unionedspider  6 місяців тому +1

      Already did that

    • @Daniel69ElGamer
      @Daniel69ElGamer 6 місяців тому

      @@unionedspider oh thanks, I only do the 1 part but to be honest, the tutorial see really good and complex, and
      I hope that you upload the 3rd part, have a nice day :3

    • @unionedspider
      @unionedspider  6 місяців тому +1

      @@Daniel69ElGamer I appreciate it, good day to you too

    • @Daniel69ElGamer
      @Daniel69ElGamer 6 місяців тому

      @@unionedspider thx :3

  • @jazzyfrog9363
    @jazzyfrog9363 5 місяців тому

    If you make a part 4 you should make it so on some floors it will kick the player out the elevator and make them participate in the game instead of camping the elevator

  • @justnikihere
    @justnikihere 4 місяці тому +1

    you're the best😭😭

  • @AlphamanRoblox14s
    @AlphamanRoblox14s 5 місяців тому +1

    I don't understand Where did you get the" ElevatorOpen = false" it tells me that it's a mistake What should I do????????????????????????????????????????????????????????????????

    • @unionedspider
      @unionedspider  5 місяців тому

      What does the error message say?

    • @AlphamanRoblox14s
      @AlphamanRoblox14s 5 місяців тому

      ​@@unionedspider sorry, I just scrolled through the feed and it turned out that I made a mistake

  • @thenyancatcookie
    @thenyancatcookie 6 місяців тому

    i am not sure if my previous comment got marked as spam or something but i was having trouble with getting the queue elevator to work, and im not sure what i did wrong. do you have any ideas about that? (nice video btw)

    • @unionedspider
      @unionedspider  6 місяців тому +1

      Depends on which part of it is working incorrectly. If there's an error message in the output that would help me as well

    • @thenyancatcookie
      @thenyancatcookie 6 місяців тому

      @@unionedspider no error message appears in the output. the doors open and everything- only problem is i cant enter the actual elevator

    • @thenyancatcookie
      @thenyancatcookie 6 місяців тому

      theres probably more information from my "held-for-review" comment but maybe because i sent links youtube took it down (they were just google drive links with screenshots, btw)

    • @unionedspider
      @unionedspider  6 місяців тому +1

      ​​@@thenyancatcookie For some reason the comment doesn't show up in the "Held for review" area but if you want you can try sending the links again and I'll recheck the comments held for review

    • @thenyancatcookie
      @thenyancatcookie 6 місяців тому

      @@unionedspider i sent like three comments, and they were all suddenly deleted off of yt :skull:
      i guess it's something to do with sending links in a comment section

  • @IceKingPlaysBrawlStars
    @IceKingPlaysBrawlStars 6 місяців тому

    Is there gonna be more parts?

  • @hyphenwtf
    @hyphenwtf 6 місяців тому

    Damn, i guess we will never know how to let npcs join the elevator lol

    • @unionedspider
      @unionedspider  6 місяців тому +1

      @@hyphenwtf Next video I will

    • @hyphenwtf
      @hyphenwtf 6 місяців тому +1

      @@unionedspider ill start the tutorial when the NPC tutorial comes out

  • @NostalgiaBuilders
    @NostalgiaBuilders 3 місяці тому

    Great video but i got an error and i have no idea what it means --> ActivelyPlaying is not a valid member of Folder "Players.abbeXDhjalmar16.ValuesFolder"

    • @unionedspider
      @unionedspider  3 місяці тому +1

      @@NostalgiaBuilders when you used instance.new to create the "ActivelyPlaying" object did you parent it to the valuesfolder?

    • @NostalgiaBuilders
      @NostalgiaBuilders 3 місяці тому

      @@unionedspider Thank you! It fixed the error! :D

    • @unionedspider
      @unionedspider  3 місяці тому +1

      @@NostalgiaBuilders No problem

  • @dinokingplez
    @dinokingplez 6 місяців тому

    can you give me game link and make it uncoppylocked for people that having trouble with and thank you for reading this
    Here my username :D
    -Dinokingplez

    • @unionedspider
      @unionedspider  6 місяців тому

      I'll make an uncopylocked version when the tutorial series is over

    • @dinokingplez
      @dinokingplez 5 місяців тому

      @@unionedspider ok thank you :D