Parts go to 0,0,0 when moving a part using a Vector3 Value inside of it

I have a lot of doors, each with a Vector3Value inside of them, being OpenPosition and ClosedPosition. I use a script to open and close it using those values, but instead it tweens them to 0,0,0? If I’m missing something, please let me know, as it is supposed to be a core mechanic.

Below is my script. Every single last door has all of the values in them.

local Tween = game:GetService("TweenService")

script.Parent.ClickDetector.MouseClick:Connect(function(Clicker)
	if Clicker:GetRankInGroup(5806137) >= 230 then
		for _,door in pairs(workspace.DormDoors:GetChildren()) do
			if not door.isOpen.Value then
				Tween:Create(door,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Position = Vector3.new(door.OpenPosition.Value)}):Play()
				wait(1)
				door.isOpen.Value = true
			elseif door.isOpen.Value then
				Tween:Create(door,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Position = Vector3.new(door.ClosedPosition.Value)}):Play()
				wait(1)
				door.isOpen.Value = false
			end
		end
	end
end)

Nevermind, I have fixed it!

For those who have the same problem as me, make sure to not put Vector3.new() over a Vector3Value object! (new code)

local Tween = game:GetService("TweenService")

script.Parent.ClickDetector.MouseClick:Connect(function(Clicker)
	if Clicker:GetRankInGroup(5806137) >= 230 then
		for _,door in pairs(workspace.DormDoors:GetChildren()) do
			if not door.isOpen.Value then
				Tween:Create(door,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Position = door.OpenPosition.Value}):Play()
				wait(1)
				door.isOpen.Value = true
			elseif door.isOpen.Value then
				Tween:Create(door,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Position = door.ClosedPosition.Value}):Play()
				wait(1)
				door.isOpen.Value = false
			end
		end
	end
end)
2 Likes

If you have found a solution to your problem, mark the helpful post as the solution.

1 Like