Help with E to open door

Okay, so I know that there how been a ton of topics like this, but I’m sure mine is different.

I am trying to make an E to open door, it works fine, but I want to make it so that you can copy and paste it without having to change the code.

This is what I have tried:
Local script:

local RunService = game:GetService("RunService")
local CharacterNearDoor = false
local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")


 
RunService.RenderStepped:Connect(function()
	  for i, v in pairs(game.Workspace.Doors:GetChildren()) do
		 if Player:DistanceFromCharacter(v.Door.Position) < 10 then
	        CharacterNearDoor = true
			v.Door.DoorGui.Enabled = true
			DoorWhichPlayerIsNear = v.Name
	    else
	        CharacterNearDoor = false
			v.Door.DoorGui.Enabled = false
			DoorWhichPlayerIsNear = nil
	    end
	end 
end)
 
UIS.InputBegan:Connect(function(Input, gameProccesedEvent)
	 if Input.KeyCode == Enum.KeyCode.E and CharacterNearDoor == true then
		game.ReplicatedStorage.DoorOpenClose:FireServer(DoorWhichPlayerIsNear)
	end
end)

ServerScript inside of each door:

--Dont worry about the opening and closing code.
local DoorOpen = false
local DoorName = script.Parent.Parent.Name
local LeftDoor = script.Parent.Parent.LeftDoor
local LeftDoorOpen = script.Parent.Parent.LeftDoorOpen
local RightDoor = script.Parent.Parent.RightDoor
local RightDoorOpen = script.Parent.Parent.RightDoorOpen
local RightDoorMetalPos = RightDoor.Metal.CFrame
local RightDoorWoodPos = RightDoor.Wood.CFrame
local LeftDoorWoodPos = LeftDoor.Wood.CFrame
local LeftDoorMetalPos = LeftDoor.Metal.CFrame

game.ReplicatedStorage.DoorOpenClose.OnServerEvent:Connect(function(player, DoorWhichPlayerIsNear)
	warn(DoorWhichPlayerIsNear)
	print(script.Parent.Parent.Name)
	if DoorWhichPlayerIsNear == DoorName then
		if DoorOpen == false then
			DoorOpen = true
			LeftDoor.Wood.CFrame = LeftDoorOpen.Wood.CFrame
			LeftDoor.Metal.CFrame = LeftDoorOpen.Metal.CFrame
			RightDoor.Wood.CFrame = RightDoorOpen.Wood.CFrame
			RightDoor.Metal.CFrame = RightDoorOpen.Metal.CFrame
		elseif DoorOpen == true then
			DoorOpen = false
			LeftDoor.Wood.CFrame = LeftDoorWoodPos
			LeftDoor.Metal.CFrame = LeftDoorMetalPos
			RightDoor.Wood.CFrame = RightDoorWoodPos
			RightDoor.Metal.CFrame = RightDoorMetalPos
		end
	end
end)

I dont get any errors, but this weird thing happens:

So i have 3 doors, that print statement that prints the name of the door that the script is inside of prints this:
Scriptinghelp
I have no idea why this happens.

Thank you for reading.

Probably because you used warn that orange thing comes out in the output. Use a print() instead.

3 Likes

I used warn to tell the difference between.

So what’s the problem? Im a little confused cause based off your print it seems to be working to me.

Also if your new to scipting oor do not know how to make a door I would suggest watching a video or read a post about it.

Doesn’t warn() not do anything to the code except to print the string inside in orange?

I do know how to make a door, but i need to make it so that it you can copy and paste the door without having to change the script.

I think the video I sent covers that you should just watch that.