What do you want to achieve?
I would like for the door to open up, by tweening the vector3 position upwards.
What is the issue?
The issue is that it goes up fine and to the position I want it to go up to, but when it comes back down it goes to a random spot.
Here is the code directly a child of the part named Door
local TweenService = game:GetService("TweenService")
local isOpen = false
local debounce = false
local DoorInfo = TweenInfo.new(3)
local DoorOpenGoal = {}
DoorOpenGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y + 5.9, script.Parent.Position.Z)
local DoorCloseGoal = {}
DoorCloseGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y - 5.9, script.Parent.Position.Z)
local DoorOpen = TweenService:Create(script.Parent, DoorInfo, DoorOpenGoal)
local DoorClose = TweenService:Create(script.Parent, DoorInfo, DoorCloseGoal)
script.Parent.ProximityPrompt.Triggered:Connect(function()
if isOpen == false and debounce == false then
debounce = true
isOpen = true
DoorOpen:Play()
wait(5)
debounce = false
elseif isOpen == true and debounce == false then
debounce = true
isOpen = false
DoorClose:Play()
wait(5)
debounce = false
end
end)
2 Likes
YosemiteMe
(YosemiteMe)
September 4, 2021, 3:05am
#2
The problem is the goals are static values that are set when the script starts and not changed later. Change the value to the original start position of the door which is…
DoorCloseGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z)
or simply…
DoorCloseGoal.Position = script.Parent.Position
2 Likes
SteveoAttano:
local TweenService = game:GetService("TweenService")
local isOpen = false
local debounce = false
local DoorInfo = TweenInfo.new(3)
local DoorOpenGoal = {}
DoorOpenGoal.Position = Vector3.new(script.Parent.Position.X + 5.9, script.Parent.Position.Y, script.Parent.Position.Z)
local DoorCloseGoal = {}
DoorCloseGoal.Position = Vector3.new(script.Parent.Position.X - 5.9, script.Parent.Position.Y, script.Parent.Position.Z)
local DoorOpen = TweenService:Create(script.Parent, DoorInfo, DoorOpenGoal)
local DoorClose = TweenService:Create(script.Parent, DoorInfo, DoorCloseGoal)
script.Parent.ProximityPrompt.Triggered:Connect(function()
if isOpen == false and debounce == false then
debounce = true
isOpen = true
DoorOpen:Play()
wait(5)
debounce = false
elseif isOpen == true and debounce == false then
debounce = true
isOpen = false
DoorClose:Play()
wait(5)
debounce = false
end
end)
there u go here i hope it helps
3 Likes