✓ Accepted answer
As for the the script not detecting when the value reaches one. The problem is that the way scripts work, they execute their code once and never again (Unless you are using ModuleScripts). But people get around this by using loops and functions. For you the best way to do this would be a function, specifically the changed function.
workspace.GameData.Close.Changed:Connect(function()
Changed means when anything about the Value changes it will execute this code. Connect just means when this event happens the code will run. Make sure when closing this piece of code you add a bracket behind the end. Put into your code it would look like this:
local sp = script.Parent
local door = sp.door
workspace.GameData.Close.Changed:Connect(function()
if workspace.GameData.Close.Value == 1 then
for i=1,door.Size.x/1.6 do
door.CFrame = door.CFrame*CFrame.new(0,-.04,0)
door.Close:Play()
end
end
end)
As for the CFrame. CFrame is not a parameter of a BasePart it is instead a type of value that stores 3D coordinates. Meaning that CFrame is used for size, position, etc. So what you want to do is put a CFrame into the position parameter of the BasePart. Like so:
door.position = CFrame.new(0, door.Position.Y * -.04, 0)
I collapsed all the needles equations in the script you had
You will want to keep everything inside the brackets of the CFrame.new. Also not sure why you have door.close:Play() written there, where you trying to do a tween? This all added to your code would be:
local sp = script.Parent
local door = sp.door
workspace.GameData.Close.Changed:Connect(function()
if workspace.GameData.Close.Value == 1 then
for i=1,door.Size.x/1.6 do
door.position = CFrame.new(0, door.Position.Y * -.04, 0)
end
end
end)