Help with proximity prompt door

Hello, so I have a proximity prompt that I want to make when you open it, it moves to “Move” and if you close it, it goes to “MoveBack”. The Move works but moveBack doesnt. Why is this?


local Move = Vector3.new(22.42, 25.266, -226.291)
local MoveBack = Vector3.new(22.42, 18.945, -226.291)
local Model = script.Parent.Parent.Door


prompt.Triggered:Connect(function()
	if prompt.ActionText == "Close" then
		prompt.ActionText = "Open"
		Model:MoveTo(Move)
	else
		prompt.ActionText = "Close"
		Model:MoveTo(MoveBack)
	end
end)

Could you please be more descriptive when your describing this because we aren’t really given an underlying problem and are just told that its not working.

What’s not working about it? And also why not use a variable instead of just watching when the proximity prompt’s action text gets changed?

Instead of going by ActionText try making the if paramater the doors’ position. For example, if when the door is closed the position is Vector3.new(10, 10, 10) then say, if door.Position == Vector3.new(10, 10, 10)… you get the idea. Not quite sure why this isn’t working in the first place, if you want to get your original system to work send me the output, and the full script :smiley:

1 Like

It would be much easier to use variables them that

1 Like

So can you please send the full script + output :smiley:

local prompt = script.Parent.ProximityPrompt

local Move = Vector3.new(22.42, 25.266, -226.291)
local MoveBack = Vector3.new(22.42, 18.945, -226.291)
local Model = script.Parent.Parent.Door


prompt.Triggered:Connect(function()
	if Model.Position == MoveBack then
		prompt.ActionText = "Open"
		Model:MoveTo(Move)
	else
		prompt.ActionText = "Close"
		Model:MoveTo(MoveBack)
	end
end)

Error: Position is not a valid member of Model "Workspace.Interior Buildings.Hotel 1.Condo.Door" - Server - Script:9

You are trying to get the position of the model, get the position of the door instead.

There are multiple parts of the door.

1 Like

Can you union them to make them one part? that way you can get the position from all of them.

I cant union because it will ruin the door. They are all different colors and stuff

The colors will not change. But if there are different materials it will ruin it…

use TweenService. Make your life so much easier. For if loops use boolean variables, helps readability and doesnt rely so heavily on exact .position values and such

for tweening the whole model, make sure you have the door properly welded & rigged and a primarypart is set

Door.rbxm (22.2 KB)

Not sure if this will work but give it a try.

local Move = Vector3.new(22.42, 25.266, -226.291)
local MoveBack = Vector3.new(22.42, 18.945, -226.291)
local Door = script.Parent.Parent.Door – Assuming the Door is a Model containing multiple parts

local prompt = script.Parent – Assuming the prompt is a child of the same object as the script

local function MoveDoor(parts, destination)
for _, part in ipairs(parts:GetChildren()) do
if part:IsA(“BasePart”) then
part:MoveTo(destination)
end
end
end

prompt.Triggered:Connect(function()
if prompt.ActionText == “Close” then
prompt.ActionText = “Open”
MoveDoor(Door, Move)
else
prompt.ActionText = “Close”
MoveDoor(Door, MoveBack)
end
end)

condo?