I have created a Noah script with the nex rooms kit for my IR remake, however, it breaks every other entity. How can I fix this?
My code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SectionValue = ReplicatedStorage:FindFirstChild("Values"):FindFirstChild("Section")
local values = {}
local ondooropened = {}
for _, v in pairs(game:GetService("ServerStorage"):FindFirstChild("Monsters"):GetDescendants()) do
if v:IsA("Model") then
spawn(function()
if string.find(v.Name, "Minion") then
return
end
if v.Parent.Name == "Special" then
return
end
if v.Parent.Name == "OnDoorOpened" then
local va = Instance.new("Folder")
va.Parent = script
va.Name = v.Name
table.insert(ondooropened, va)
return
end
local va = Instance.new("IntValue")
va.Parent = script
va.Name = v.Name
va.Value = -1
table.insert(values, va)
end)
end
end
spawn(function()
while wait(1) do
for _, v in pairs(values) do
if v.Value ~= -1 then
v.Value -= 1
if v.Value <= 0 then
v.Value = math.random(100, 600)
local c = game:GetService("ServerStorage"):FindFirstChild("Monsters"):WaitForChild(SectionValue.Value .. "Section"):FindFirstChild(v.Name):Clone()
c.Parent = game:GetService("Workspace"):FindFirstChild("Entities")
end
end
end
end
end)
SectionValue.Changed:Connect(function()
local newv = SectionValue.Value
for _, v in pairs(values) do
if string.split(v.Name, "-")[1] ~= newv then
v.Value = -1
end
end
end)
game:GetService("ReplicatedStorage"):FindFirstChild("Values"):FindFirstChild("DoorNumber").Changed:Connect(function()
local newv = game:GetService("ReplicatedStorage"):FindFirstChild("Values"):FindFirstChild("DoorNumber").Value
for _, v in pairs(values) do
local splitValue = string.split(v.Name, "-")
local splitNumber = tonumber(splitValue[2])
if newv and splitNumber then
if newv >= splitNumber then
if splitValue[1] == SectionValue.Value then
if not v:FindFirstChild("used") then
local f = Instance.new("Folder", v)
f.Name = "used"
v.Value = math.random(0, 0)
end
end
end
end
end
for _, v in pairs(ondooropened) do
local splitValue = string.split(v.Name, "-")
local splitNumber = tonumber(splitValue[2])
if (newv and splitNumber) or v.Name == "Noah" then
if v.Name == "Noah" or (newv >= splitNumber) then
if (splitValue[1] == SectionValue.Value) or v.Name == "Noah" then
local chance = math.random(1, 40)
if v.Name == "Noah" then
chance = math.random(1, 20)
end
if (not v:FindFirstChild("used")) then
local f = Instance.new("Folder", v)
f.Name = "used"
end
if chance == 1 and workspace.ecs.Value == true then
task.delay(0.1, function()
local c = game:GetService("ServerStorage"):FindFirstChild("Monsters"):WaitForChild(SectionValue.Value .. "Section"):FindFirstChild("OnDoorOpened"):FindFirstChild(v.Name):Clone()
if (not workspace.Entities:FindFirstChild(c.Name)) or v.Name == "Noah" then
if not (v.Name == "Noah" or v.Name == "A-150" or v.Name == "A-80" or v.Name == "A-258" or v.Name == "A-278" or v.Name == "A-245" or v.Name == "A-246" or v.Name == "John" or v.Name == "Mario" or v.Name == "kardeenil" or v.Name == "A-200" or v.Name == "X-200") then
wait(math.random(1, 20))
end
c.Parent = game:GetService("Workspace"):FindFirstChild("Entities")
elseif workspace.Entities:FindFirstChild(c.Name) then
c:Destroy()
end
end)
end
end
end
end
end
end)