RenderStepped = RunService.RenderStepped:Connect(function()
local LastInput = UserInputService:GetLastInputType()
local ClosestDoor = nil
for _, v in pairs(Plots:GetDescendants()) do
if v.Name == 'Door' and v:IsA('BasePart') then
InsideDistance = (v.CFrame.p - HumanoidRootPart.CFrame.p).magnitude
if not ClosestDoor or InsideDistance <= ClosestDoor[1] then
ClosestDoor = {InsideDistance, v}
end
end
end
for _, v in pairs(Doors:GetDescendants()) do
if v.Name == 'Door' and v:IsA('BasePart') then
OutsideDistance = (v.CFrame.p - HumanoidRootPart.CFrame.p).magnitude
if not ClosestDoor or OutsideDistance <= ClosestDoor[1] then
ClosestDoor = {OutsideDistance, v}
end
end
end
if not ClosestDoor then return end
local Distance = ClosestDoor[1]
Door = ClosestDoor[2]
if Distance <= 5 then
local EditMenu = PlayerGui.HUD:FindFirstChild('EditMenu')
if EditMenu.Visible then return end
local EnterClone = PlayerGui:FindFirstChild('Enter')
if EnterClone then return end
local EnterClone = Enter:Clone()
if not EnterClone then return end
if LastInput == Enum.UserInputType.Gamepad1 then
EnterClone.Control.PC.Visible = false
EnterClone.Control.Controller.Visible = true
EnterClone.Control.ImageTransparency = 1
EnterClone.Control.Controller.ImageRectOffset = ButtonImages[Settings.ControllerKey][1]
else
EnterClone.Control.PC.Visible = true
EnterClone.Control.Controller.Visible = false
EnterClone.Control.PC.Text = Settings.PCKey
end
if InsideDistance <= 5 then
EnterClone.Control.Label.Text = 'to Leave!'
else
EnterClone.Control.Label.Text = 'to Enter!'
end
EnterClone.Parent = PlayerGui
Tween(EnterClone.Control, UDim2.new(0.45, 0, 0.75, 0), 0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.In):Play()
else
local EnterClone = PlayerGui:FindFirstChild('Enter')
if not EnterClone then return end
Tween(EnterClone.Control, UDim2.new(0.45, 0, 0.775, 0), 0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out):Play()
wait(0.25)
EnterClone:Destroy()
end
end)
UserInputService.InputBegan:Connect(function(input)
local CurrentTime = tick()
if CurrentTime - LastTeleportTime < Settings.Timeout then
return
end
if input.KeyCode == Enum.KeyCode[Settings.ControllerKey] or input.KeyCode == Enum.KeyCode[Settings.PCKey] then
local EnterClone = PlayerGui:FindFirstChild('Enter')
if not EnterClone then return end
local UIClone = Transition:Clone()
UIClone.Parent = PlayerGui
Tween(UIClone.Left, UDim2.new(0, 0, 0, 0), 0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In):Play()
Tween(UIClone.Right, UDim2.new(0.5, 0, 0, 0), 0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In):Play()
HumanoidRootPart.Anchored = true
wait(0.5)
if OutsideDistance <= 5 then
for _, v in pairs(Plots:GetDescendants()) do
if v.Name == Player.Name then
Character:SetPrimaryPartCFrame(v.Extras.InsideDoor.Teleport.CFrame)
Side = 'Indoors'
end
end
elseif InsideDistance <= 5 then
print(1)
for _, v in pairs(Doors:GetDescendants()) do
if v.Name == Player.Name then
Character:SetPrimaryPartCFrame(v.Teleport.CFrame)
Side = 'Outside'
end
end
end
LastTeleportTime = CurrentTime
wait(0.5)
Tween(UIClone.Left, UDim2.new(-0.5, 0, 0, 0), 0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out):Play()
Tween(UIClone.Right, UDim2.new(1, 0, 0, 0), 0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out):Play()
local HUD = PlayerGui:FindFirstChild('HUD')
if not HUD then return end
local HouseMenu = HUD:FindFirstChild('HouseMenu')
if not HouseMenu then return end
local LevelMenu = HUD:FindFirstChild('LevelMenu')
if not LevelMenu then return end
if Side == 'Indoors' then
HouseMenu.Visible = true
LevelMenu.Visible = false
else
HouseMenu.Visible = false
LevelMenu.Visible = true
end
HumanoidRootPart.Anchored = false
wait(0.5)
UIClone:Destroy()
end
end)
Basically, when they press the button it should teleport them from one door to another door. The outside door model is named after the player, meanwhile the inside door is inside of a plot model named after the player.
When a player is near the outside door, it should teleport them to the inside door.
Like
If player is near NinjoOnline Outside Door then
Teleport player to NinjoOnline Inside Door
To do that, I’d have to check if they closer to an inside or outside door. Then loop thru the corresponding locations of the doors.
So if near NinjoOnline’s Outside Door (which the model would be named NinjoOnline) then search thru the plots folder and find the plot called NinjoOnline.