How can i make a part load in a map

so theres actully i few things i want to do but i dont want to make a bunch of different posts about it so ya

  1. i want it so when you touch a part it will load in a map i put all the maps in folders so that will help (i dont need this just think it would help with lag)
  2. i want to make a ui pop up and then go away after 5 seconds
  3. i want it so when you touch the part it waits 5 seconds and then teleports you

sry if this is to much to ask for but i think its better than making 3 separate posts

Lets say you have your maps in a folder called Maps (in server storage).

Add a Script in your part, in this script you should utilize Roblox’s built in Touched event, then you should either clone the map or change the maps parent to the workspace, finally spawn a new thread, wait 5 seconds and teleport the player.

Example:

local Players = game:GetService("Players")
local SS = game:GetService("ServerStorage")

local Part = script.Parent
local Maps = SS.Maps

local debounce = {}

local function OnPartTouched(hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)

    if not player then return end
    if debounce[player.UserId] then return end

    local map = Maps.MapName:Clone()
    map.Parent = game.Workspace
    debounce[player.UserId] = true
    task.spawn(function()
        task.wait(1)
        debounce[player.UserId] = nil
        task.wait(4)
    end)
end

When do you want this to happen, and what is the name of the UI (can you provide a screenshot of the explorer for the UI)

sry for the late reply but i want the ui to pop up and then the player gets teleported so like a loading screen ui the name of the ui doesnt matter you can just put it in the script since the ui isnt made yet but it would be an image label

also theres separate folders for each map so like map 1, map 2, etc

Ok, so the script should look something like this:


local Players = game:GetService("Players")
local SS = game:GetService("ServerStorage")

local Part = script.Parent

local debounce = {}

local function OnPartTouched(hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)

    if not player then return end
    if debounce[player.UserId] then return end

    local map = SS.Map1.MapName:Clone()
    map.Parent = game.Workspace
    debounce[player.UserId] = true

    local PlrGui = player.PlayerGui
    local ScreenGui = PlrGui.LoadingUI
    local Label = ScreenGui.ImageLabel

    task.spawn(function()
        Label.Visible = true
        task.wait(1)
        debounce[player.UserId] = nil
        task.wait(4)
        Label.Visible = false
        local char = player.Character
        char.HumanoidRootPart.Position = map.TPPart.Position
    end)
end

Part.Touched:Connect(OnPartTouched)
1 Like

ill try that when i have time

ok so im a few things

  1. where do i put the ui that i want to pop up is it like StarterGui of something else (btw the ui would be named LoadingUi)

  2. the map folders are named level1 level2 and level3 but i can just change line 14 right?

also would i need a part named TPPart i see that inn line 29

its not working yet since i dont have the ui yet ima make it tho