So your v.Model.PrimaryPart
is probably nil
for some reason. Make it be not nil
.
Use the debugger like I said to find the problem, or try some basic things like print(v.Model.PrimaryPart)
So your v.Model.PrimaryPart
is probably nil
for some reason. Make it be not nil
.
Use the debugger like I said to find the problem, or try some basic things like print(v.Model.PrimaryPart)
Sorry, went to bed.
I tried printing (v.Model.PrimaryPart.Name) and I got nil again.
So, I just spent an hour and 30 minutes adding Cameras. Now this is the result.
This is the new code:
local function AddGUIs()
for i, v in pairs(Module) do
local SomeConstant = 5
Print("InPairs for AddGUI Started")
local NewVPF = Instance.new("ViewportFrame")
NewVPF.BackgroundColor3 = Color3.fromRGB(255,255,255)
NewVPF.BackgroundTransparency = 1
NewVPF.Name = i
NewVPF.Parent = loc
local Item = game.ReplicatedStorage.Assets.Data.Furniture[i]:Clone()
Item.Parent = NewVPF
local Cam = Instance.new("Camera")
Cam.Parent = NewVPF
Cam.CameraSubject = Item
NewVPF.CurrentCamera = Cam
--[[
if v.Model:IsA("Model") then
Print(v.Model.PrimaryPart.Name)
Cam.CFrame = CFrame.new(v.Model.PrimaryPart.CFrame.Position + (v.Model.PrimaryPart.CFrame.LookVector * SomeConstant ), v.Model.PrimaryPart.Position)
else
]]
Cam.CFrame = CFrame.new(v.Model.CamPart.CFrame.Position + (v.Model.CamPart.CFrame.LookVector * SomeConstant ), v.Model.CamPart.Position)
-- end
Cam.Focus = CFrame.new(0,0,Module[i].CameraPan)
local SelectButton = Instance.new("TextButton")
SelectButton.Text = ""
SelectButton.Font = Enum.Font.Gotham
SelectButton.TextColor3 = Color3.fromHSV(0, 0, 1)
SelectButton.BackgroundTransparency = 0.999
SelectButton.Size = UDim2.new(1,0,1,0)
SelectButton.Parent = NewVPF
SelectButton.Name = "Select"
local NewCorner = Instance.new("UICorner")
NewCorner.Parent = NewVPF
NewCorner.CornerRadius = UDim.new(0.15,0)
Print("Created ViewportFrame, SelectButton, and Corner, success, instance string instance, "..i.."/"..ModuleAmount)
end
loaded = true
end