Attempt to index nil with CFrame?

I have a script which locates the primary part of a area, but it doesn’t seem to work?

repeat wait() until script.Parent.Boss 
repeat wait() until game.Players
repeat wait() until script.Parent.Config.TimeAlive
local WaitTime = 1
local TimeAlive = script.Parent.Config.TimeAlive.Value
local mag = 4000
local judgementHallCFrame = game.Workspace.JudgementHall.PrimaryPart.CFrame
local Phase = 0 

Help would be very much appreciated thank you!

1 Like

Are you sure that game.Workspace.JudgementHall.PrimaryPart is not empty and leads to a part.

Well there’s nothing but PrimaryPart should be defined as near as the entire thing or center of it no? And PrimaryPart is still being defined even though it’s not a child of it since it’s the basepart of the model. That’s why I dont know why it doesn’t work

1 Like

You have to set model.PrimaryPart value to a part you want to count as center

PrimaryPart should be the part that is in the center of the model, but you can change the pivot position so no worries