-
What do i want to achieve?
I want the Paper to stop running into a CFrame error – ATTENTION: Look in the lua block below, the one in the what is the issue section, i have pinpointed exactly where the error is occuring -
What is the issue?
function RunPrinter(Printer)
if Printer:GetAttribute("PaperFolders") > 9 then return end
local Paper = game:GetService("ServerStorage"):WaitForChild("TycoonAssets"):WaitForChild("Paper"):Clone()
Paper.Anchored = true
Paper.CanCollide = false
if Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders") + 1) then
Paper.Parent = Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders") + 1)
end
if Printer:GetAttribute("PaperFolders") < 1 then
local Folder = Instance.new("Folder", Printer:WaitForChild("Papers"))
Folder.Name = Printer:GetAttribute("PaperFolders") + 1
Paper.Parent = Folder
Folder:SetAttribute("MaxPapers", 10)
Folder:SetAttribute("CurrentPapers", 0)
Printer:SetAttribute("PaperFolders", Printer:GetAttribute("PaperFolders") + 1)
end
local function SetPaper()
if Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders")):GetAttribute("CurrentPapers") >= Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders")):GetAttribute("MaxPapers") then
local Folder = Instance.new("Folder", Printer:WaitForChild("Papers"))
Folder.Name = Printer:GetAttribute("PaperFolders") + 1
Paper.Parent = Folder
Folder:SetAttribute("MaxPapers", 10)
Folder:SetAttribute("CurrentPapers", 0)
Printer:SetAttribute("PaperFolders", Printer:GetAttribute("PaperFolders") + 1)
Paper.CFrame = Printer:WaitForChild("StartPaperPositions"):FindFirstChild(Printer:GetAttribute("PaperFolders")).CFrame
Paper.Name = Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders")):GetAttribute("CurrentPapers") + 1
else
Paper.Parent = Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders"))
for i, v in pairs(Printer:WaitForChild("Papers"):GetChildren()) do
if v:GetAttribute("CurrentPapers") >= v:GetAttribute("MaxPapers") then
Paper:Destroy()
else
if v:GetAttribute("CurrentPapers") < 1 then
if not v:GetAttribute("CurrentPapers") then print("NO CURRENTPAPER FOR: ", v.Name) end
v:SetAttribute("CurrentPapers", 1)
Paper.CFrame = Printer:WaitForChild("StartPaperPositions"):FindFirstChild(Printer:GetAttribute("PaperFolders")).CFrame
Paper.Name = v:GetAttribute("CurrentPapers")
else
v:SetAttribute("CurrentPapers", v:GetAttribute("CurrentPapers") + 1)
local CurrentNumber = v:GetAttribute("CurrentPapers") - 1
print("NUMBER:", v:GetAttribute("CurrentPapers") - 1)
local FoundInstance = v:FindFirstChild(CurrentNumber)
Paper.Name = v:GetAttribute("CurrentPapers")
print(v:GetAttribute("CurrentPapers"))
print(typeof(FoundInstance))
Paper.CFrame = FoundInstance.CFrame + Vector3.new(0, .1, 0) -- The error is here
end
end
end
end
end
SetPaper()
end
3 What solutions have i tried so far?
I have looked all over the devforum but cant find an answer
Code:
-- This is an example Lua code block
function RunPrinter(Printer)
if Printer:GetAttribute("PaperFolders") > 9 then return end
local Paper = game:GetService("ServerStorage"):WaitForChild("TycoonAssets"):WaitForChild("Paper"):Clone()
Paper.Anchored = true
Paper.CanCollide = false
if Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders") + 1) then
Paper.Parent = Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders") + 1)
end
if Printer:GetAttribute("PaperFolders") < 1 then
local Folder = Instance.new("Folder", Printer:WaitForChild("Papers"))
Folder.Name = Printer:GetAttribute("PaperFolders") + 1
Paper.Parent = Folder
Folder:SetAttribute("MaxPapers", 10)
Folder:SetAttribute("CurrentPapers", 0)
Printer:SetAttribute("PaperFolders", Printer:GetAttribute("PaperFolders") + 1)
end
local function SetPaper()
if Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders")):GetAttribute("CurrentPapers") >= Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders")):GetAttribute("MaxPapers") then
local Folder = Instance.new("Folder", Printer:WaitForChild("Papers"))
Folder.Name = Printer:GetAttribute("PaperFolders") + 1
Paper.Parent = Folder
Folder:SetAttribute("MaxPapers", 10)
Folder:SetAttribute("CurrentPapers", 0)
Printer:SetAttribute("PaperFolders", Printer:GetAttribute("PaperFolders") + 1)
Paper.CFrame = Printer:WaitForChild("StartPaperPositions"):FindFirstChild(Printer:GetAttribute("PaperFolders")).CFrame
Paper.Name = Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders")):GetAttribute("CurrentPapers") + 1
else
Paper.Parent = Printer:WaitForChild("Papers"):FindFirstChild(Printer:GetAttribute("PaperFolders"))
for i, v in pairs(Printer:WaitForChild("Papers"):GetChildren()) do
if v:GetAttribute("CurrentPapers") >= v:GetAttribute("MaxPapers") then
Paper:Destroy()
else
if v:GetAttribute("CurrentPapers") < 1 then
if not v:GetAttribute("CurrentPapers") then print("NO CURRENTPAPER FOR: ", v.Name) end
v:SetAttribute("CurrentPapers", 1)
Paper.CFrame = Printer:WaitForChild("StartPaperPositions"):FindFirstChild(Printer:GetAttribute("PaperFolders")).CFrame
Paper.Name = v:GetAttribute("CurrentPapers")
else
v:SetAttribute("CurrentPapers", v:GetAttribute("CurrentPapers") + 1)
local CurrentNumber = v:GetAttribute("CurrentPapers") - 1
print("NUMBER:", v:GetAttribute("CurrentPapers") - 1)
local FoundInstance = v:FindFirstChild(CurrentNumber)
Paper.Name = v:GetAttribute("CurrentPapers")
print(v:GetAttribute("CurrentPapers"))
print(typeof(FoundInstance))
Paper.CFrame = FoundInstance.CFrame + Vector3.new(0, .1, 0)
end
end
end
end
end
SetPaper()
end