All my doors use this script, and all of them, in loads of different places and models, have broken after the most recent update. The only update to the place itself has been fixing some bricks with the wrong material, nothing else has changed for weeks.
local dir = Vector3.new(0,0,-1) --direction of model motion from its initial starting point to end point
dir = dir.unit
local override = true --allows buttons to change action before it is completed (i.e. close it before it completely opens/ open before completely closing)
local offset = 8 -- how far the door moves in dir !Always positive!
local speed = 1.5 --studs per second, thats about 1.65 mi/hour !Always positive!
local closetime = 6 -- if you want the door to close automatically set it to the number of nonzero seconds after it opens that it waits until starting to close
--Edit the above
local End = script.Parent:GetModelCFrame().p + dir * offset
local Start = script.Parent:GetModelCFrame().p
local parts = script.Parent:GetChildren()
local dist = End - Start
local status = "closed"
local db = true
override = (closetime <= 0) and override
for _, v in pairs(parts) do
if not v:IsA("BasePart") then
table.remove(parts, _)
else
parts[_] = {v, closed = v.CFrame, open = v.CFrame + offset * dir}
end
end
function Update()
if not override and not db then return end
db = false -- has no effect if override is true
status = status == "closed" and "open" or "closed"
local pos = status == "closed" and Start or End
local ndir = pos == End and -1 or 1
local travel = (pos - script.Parent:GetModelCFrame().p).magnitude
local oldstate = status
while travel > 0 and status == oldstate do
local os = not os and oldstate or os
travel = travel - speed * wait()
travel = travel<0 and 0 or travel
for _, v in pairs(parts) do
v[1].CFrame = v[1].CFrame - v[1].CFrame.p + v[os].p + travel * ndir * dir
end
print(travel == 0 and closetime > 0, closetime > 0)
if travel == 0 and closetime > 0 and status == "open" then
wait(closetime)
status = status == "closed" and "open" or "closed"
pos = status == "closed" and Start or End
ndir = pos == End and -1 or 1
travel = (pos - script.Parent:GetModelCFrame().p).magnitude
oldstate = status
os = status
end
end
db = true
end
script.Parent.Parent.Button.ClickDetector.MouseClick:connect(Update)
:46: Attempt to index field ‘?’ (a nil value)
Line 46:
v[1].CFrame = v[1].CFrame - v[1].CFrame.p + v[os].p + travel * ndir * dir
I don’t understand why you are posting this in bug reports without properly debugging it for yourself. You need to narrow down the specific problem before you post here.
We can’t debug the script ourselves because you did not provide the full model.
I can’t debug it because I didn’t make it and the guy who did doesn’t play anymore. Plus, as I said, it has been working for years and only broke after the recent ROBLOX update.
[quote] I don’t understand why you are posting this in bug reports without properly debugging it for yourself. You need to narrow down the specific problem before you post here.
We can’t debug the script ourselves because you did not provide the full model.
Either v[os] is nil, or v[os].p is nil. [/quote]
I can’t debug it because I didn’t make it and the guy who did doesn’t play anymore. Plus, as I said, it has been working for years and only broke after the recent ROBLOX update.[/quote]
You have the model, don’t you?
[quote] [quote=“Merely” post=20287]I don’t understand why you are posting this in bug reports without properly debugging it for yourself. You need to narrow down the specific problem before you post here.
We can’t debug the script ourselves because you did not provide the full model.
Either v[os] is nil, or v[os].p is nil. [/quote]
I can’t debug it because I didn’t make it and the guy who did doesn’t play anymore. Plus, as I said, it has been working for years and only broke after the recent ROBLOX update.[/quote]
You have the model, don’t you?[/quote]
[quote] I don’t understand why you are posting this in bug reports without properly debugging it for yourself. You need to narrow down the specific problem before you post here.
We can’t debug the script ourselves because you did not provide the full model.
Either v[os] is nil, or v[os].p is nil. [/quote]
I can’t debug it because I didn’t make it and the guy who did doesn’t play anymore. Plus, as I said, it has been working for years and only broke after the recent ROBLOX update.[/quote]
[quote] [quote=“Merely” post=20287]I don’t understand why you are posting this in bug reports without properly debugging it for yourself. You need to narrow down the specific problem before you post here.
We can’t debug the script ourselves because you did not provide the full model.
Either v[os] is nil, or v[os].p is nil. [/quote]
I can’t debug it because I didn’t make it and the guy who did doesn’t play anymore. Plus, as I said, it has been working for years and only broke after the recent ROBLOX update.[/quote]
I always thought you are a scripter. Oh ok.[/quote]
I do script, but not that. Only two things in the labs aren’t scripted by me, the gun and the doors, and both are now broken. I have some more advanced stuff but it’s all little more than a tech demo.