Cell Door opener script not working

This script was made in 2016 or 2017 and it worked perfectly back then but now it’s not working, I’m guessing it’s very outdated but I am hoping someone can help me fix it or lead me in the right direction as I am not a scripter nor am I able to afford one.

image
The script inside the cell door named “CellController” is:

ref=script.Parent.ref
ref.Changed:connect(function()
	if ref.Value==nil then return end
	if ref.Value.Parent==nil then ref.Value=nil return end
	script.Parent.door.sign.SurfaceGui.TextLabel.Text=ref.Value.Name
end)
local door_debounce=false
function setDoorState(state)
	if door_debounce then repeat wait(math.random(1,10)/10) until not door_debounce end door_debounce=true
	if script.Parent.doorstate.Value==state then return end
	script.Parent.doorstate.Value=state
	if state==true then --Open
	for i=1, 10 do wait()
		for _,p in pairs(script.Parent.door:children()) do
			p.CFrame=p.CFrame*CFrame.new(0,0,-.02)
		end
	end wait(0.5)
	for i=1, 40 do wait()
		for _,p in pairs(script.Parent.door:children()) do
			p.CFrame=p.CFrame*CFrame.new(-.1,0,0)
		end
	end
	else --Close
		for i=1, 40 do wait()
			for _,p in pairs(script.Parent.door:children()) do
				p.CFrame=p.CFrame*CFrame.new(.1,0,0)
			end
		end wait(0.5)
		for i=1, 10 do wait()
			for _,p in pairs(script.Parent.door:children()) do
				p.CFrame=p.CFrame*CFrame.new(0,0,.02)
			end
		end
	end
	door_debounce=false
end
script.Parent.action_door.Changed:connect(function()
	setDoorState(script.Parent.action_door.Value)
end)

image
The script inside of the Door Controller itself is:

script.Parent.Selected:connect(function(mouse)
	mouse.Button1Down:connect(function()
		local t=mouse.Target
		if t==nil then return end
		if t.Parent==nil then return end
		if t.Parent.Parent:FindFirstChild("action_door") then
			if game.Players.LocalPlayer:DistanceFromCharacter(t.Position)<10 then
			t.Parent.Parent.action_door.Value=not t.Parent.Parent.doorstate.Value
			end
		end
	end)
end)

It doesn’t work because action_foor is (server) value. The client cannot influence the server. I’m surprised how this could have worked before.

How would I go about fixing this? I’m not a scripter so I don’t know much to anything about it.

Try creating “RemoteFunction” with name “DoorOpenEvent” and put it in “Cell Door”. In the local script, replace the line “t.Parent.Parent.action_door.Value=not t.Parent.Parent.doorstate.Value” with “t.Parent.Parent:WaitForChild(“DoorOpenEvent”):InvokeServer()”.

In “CellController”
replace “script.Parent.action_door.Changed:connect(function()
setDoorState(script.Parent.action_door.Value)
end)” to “script.Parent:WaitForChild(“DoorOpenEvent”).OnServerInvoke = function()
script.Parent.action_door.Value=not script.Parent.doorstate.Value
setDoorState(script.Parent.action_door.Value)
end”

Should work.

1 Like

I’m getting these red line errors


Have you added a “RemoteFunction” named “DoorOpenEvent”?

Fixed it, I removed the " ‘’ " and used " " instead and removed the errors and fixed the door :slight_smile: Thank you for helping