How would you be able to make a door system like adopt me?

What I want to achieve is making a door system like adopt me, if you get close to it the door opens for you and if you touch the neon white part your character will walk into the door en Teleport with a fading screen.

I’ve tried: Making a touch part which opens the door… And to move the player in the door I tried to use MoveToPoint. For the fading screen I tried tweening but that also failed as I am fairly new to tweening.

Thanks for reading! I don’t need full on scripts or anything but if you would like to I don’t mind!

4 Likes

You can use .Magnitude and tweenservice(put into starterGUI as local script)

local TS = game:GetService("TweenService")
local UI = --Reference the UI that you want to tween
local Tween = tween = TS:Create(UI, 3, {BackgroundTransparency = 1}, 1, true)
local Part = -- Reference the door

local HumanoidRootPart = game.Player.Character:WaitForChild("HumanoidRootPart")
while wait() do
    if (door.Position - HumanoidRootPart.Position).Magnitude <= 10 then
        --Door opens
    else
        --DoorCloses
end

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("HumanoidRootPart") then
        -- teleport the player
    end
end)
2 Likes

Does this also let the player automatically walk into the door? I haven’t tried it yet btw. I’m at school rn.

1 Like

if you want it to walk in you just tween the player in once the player touches the door with more script

1 Like

Could you show an example please?

to move the player, add this to the previously mentioned script

local humanoid  = game.Player.Character:FindFirstChild("Humanoid")
 humanoid:MoveTo(Vector3.New(3,13,33))

For me personally, I’d use :DistanceFromCharacter().

Actually, don’t do that, I just found a bug report explaing the issues with :DistanceFromCharacter() (Here), use Magnitude as @VegetationBush mentioned, but I improved upon it by using the :GetBoundingBox() method allowing to not rely on one singular static part.

I’d also recommend reading the resource by @colbert2677.

local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Player")

local model = PathToModel -- use the resource i posted
local tween = tweenService:Create(...) -- add arguments

while wait(0.1) do
    for _, player in ipairs(Players:GetPlayers()) do -- use ipairs because getplayers is an array, better performance in a loop.
        if player.Character then
             if (player.Character:GetBoundingBox().p - model:GetBoundingBox().p).Magnitude <= 10 then -- first argument of it is cframe, CFrame has the p field
                 tween:Play()
                 tween.Completed:Wait() -- wait for it to end before the next iteration
            end
        end
    end
end
6 Likes

I made a system just like this not too long ago, if anyone would like to see or use the full source code you can download it here.

This system is run completely on the client side, and the script is located under StarterPlayerScripts.

5 Likes

What’s the download link? It’s not working.

1 Like

Hey… So this is hella cool! but one suggestion… Could you ever try making a way I could connect 2 rooms with a door? Basically cuz i made like a house with 2 rooms inside. OF course they are completely separated off each other and stuff, but i cant seem to find a way i can connect those 2 same rooms with a door in between them!

Nonetheless, the system is hella nice and resolved a lag issue big time!

1 Like