Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

PrimaryPart a nil value?

Asked by 6 years ago

Why am I getting this error?

Workspace.Oven.OvenDoor.Handle.Script:7: attempt to index field 'PrimaryPart' (a nil value)

local Handle = script.Parent
local OvenDoor = Handle.Parent.OvenDoor

function openOven()
    for i = 1, 12 do
        print("Opening...")
        OvenDoor:SetPrimaryPartCFrame(script.Parent.Parent.PrimaryPart.CFrame * CFrame.Angles(0, 0, math.rad(5)))       
        wait()
    end
end

Handle.ClickDetector.MouseClick:connect(openOven)
0
The primary part isn't set Griffi0n 315 — 6y
0
And how might I set it? ziggygreen 17 — 6y
0
set the primary part, by going to explorer, clicking on model, go to properties, click primary part, and then click a part in the model (in explorer) abnotaddable 920 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You need to set the primary part for the model. You can do this one of two ways:

local Model = workspace.Model;
Model.PrimaryPart = Model.SomePart;

Or, you can manually set it:

  • Click the model in explorer.
  • Click the blank input box next to the text "PrimaryPart" in the properties section. The mouse cursor should change.
  • Finally, click on a part that is a child (descendant) of the model that you want to be the primary part.
Ad

Answer this question