What do you want to achieve?
I would like for both of the doors to both open and close.
What is the issue?
To be honest I do not know what the issue is, nothing happens when the prompt is triggered, and their for all I am left with is an error that I can’t solve.
Here is my code
--//Services\\--
local TweenService = game:GetService("TweenService")
--//Extra Variables\\--
local isOpen = false
local debounce = false
--//Tween Info\\--
local DoorInfo = TweenInfo.new(3)
--//Create Goals\\--
local Door1OpenGoal = {}
Door1OpenGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z + 3.8)
local Door2OpenGoal = {}
Door2OpenGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z -3.8)
local Door1CloseGoal = {}
Door1CloseGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z - 3.8)
local Door2CloseGoal = {}
Door2CloseGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z + -3.8)
--//Create Tweens\\--
local Door1Open = TweenService:Create(script.Parent.Door1, DoorInfo, Door1OpenGoal)
local Door2Open = TweenService:Create(script.Parent.Door2, DoorInfo, Door2OpenGoal)
local Door1Close = TweenService:Create(script.Parent.Door1, DoorInfo, Door1CloseGoal)
local Door2Close = TweenService:Create(script.Parent.Door2, DoorInfo, Door2CloseGoal)
function OpenAndCloseDoors ()
if isOpen == false and debounce == false then
debounce = true
isOpen = true
Door1Open:Play()
Door2Open:Play()
wait(5)
Door1CloseGoal.Position = script.Parent.Position
Door2CloseGoal.Position = script.Parent.Position
debounce = false
elseif isOpen == true and debounce == false then
debounce = true
isOpen = false
Door1Close:Play()
Door2Close:Play()
wait(5)
debounce = false
end
end
script.Parent.KeycardReader1.KeycardReader1Hitbox.ProximityPrompt.Triggered:Connect(OpenAndCloseDoors)
script.Parent.KeycardReader2.KeycardReader2Hitbox.ProximityPrompt.Triggered:Connect(OpenAndCloseDoors)
I believe the error is happening because you are trying to get the Position of a model. In this case the model is called “Door”. Models do not have a Position so this would not work.
Models can however have a primary part, which you can get the CFrame of in many ways.
I know why the error is happening, I just currently can’t think of a solution.
If anyone could add on to this, that would be great.
Oh wow it does work can’t belive you wrote the whole script for me lol, thanks. I am gonna look at the difference between the two to see what I done wrong.
Now the only problem is the Closing, it closes, but not the position I want it do despite me reversing what I did when I opened it if that makes sense.
Their are two halfs of the door, one half goes one way along the X axis, and the other goes the other way. I want it to happen whenever I trigger a prompt.