What does attempt to index nil with 'CFrame mean?

So i get this error message:

ServerScriptService.Main Framework:64: attempt to index nil with 'CFrame

how can i fix this?

here’s the code:
Bildschirmfoto 2022-10-02 um 4.16.20 PM

Hi there

that most likely means that your plate is nil print before doing HumanoidRootPart.CFrame = …
or maybe add

if HumanoidRootPart and (#Players> = ) .. and plate then

where should i add that? lol help me pls

1 Like

In your Line 63 add before then and plate then

where in my code is “then and plate then”

if HumanoidRootPart and #Players >= minimumPlayers and plate then

Line 63

it still doesn’t work lol help

Could you show us the Plates Folder/Model you pulling the Plate from?

can I see the children of the Plates folder not just the folder itself?

Alright, it seems like your FindFirstChild for the plate is off.

local plate = Plates:FindFirstChild("Plate"..i)
You’d want local plate = Plates:FindFirstChild("i"..i)

1 Like


now i get this

Well now you actually have the Model.
Naturally plate is the Model object which doesn’t have a CFrame.

You’d want to do plate.PrimaryPart.CFrame

1 Like

where do i put the plate.PrimaryPart.CFrame in the code?

replace plate.CFrame with place.PrimaryPart.CFrame where you’re setting the HumanoidRootPart CFrame, line 64

Also a quicker method to moving a Character is using PivotTo on their model!

PlayerCharacter:PivotTo(CFrame)
Saves some extra typing trying to do PlayerCharacter.HumanoidRootPart

still not working now i get a other error here’s the full code can you please edit the code and send me the correct one im not able to do it .-.



local EventsModule = require(script:WaitForChild("EventsModule"))
local MethodNames = {}

for MethodName, Method in pairs(EventsModule) do
	if type(Method) == "function" then
		table.insert(MethodNames, MethodName)
	end
end



local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")

local Contestants = Teams:WaitForChild("Contestants")
local Spectators = Teams:WaitForChild("Spectators")

local Remotes = ReplicatedStorage:WaitForChild("Remotes")

local Values = ReplicatedStorage:WaitForChild("Values")
local Status = Values:WaitForChild("Status")
local GameRunning = Values:WaitForChild("GameRunning")

local Assets = ReplicatedStorage:WaitForChild("Assets")



local intermissionLength = 15
local timeBetweenEvents = 10
local minimumPlayers = 0

local function intermission()
	GameRunning.Value = false
	for i = intermissionLength, 0 , -1 do
		wait(1)
		Status.Value = "Intermission: ".. i .." seconds"
	end
	Status.Value = "Round Starting!"
	GameRunning.Value = true
end

local function startRound()
	
	
	
	local Plates = Assets.plates:Clone()
	Plates.Parent = game.Workspace
	
	local Players = game.Players:GetPlayers()
	local PlayersAlive = {}
	local PlatesAlive = {}
	
	
	
	for i, player in pairs(Players) do
		local plate = Plates:FindFirstChild("i"..i)
		local character = player.Character
		
		local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
		if HumanoidRootPart and #Players >= minimumPlayers then
			HumanoidRootPart.CFrame = place.PrimaryPart.CFrame * CFrame.new(0,3,0)
			player.serverData.playerPlate.Value = i
			
			local plateOwner = Instance.new("StringValue")
			plateOwner.Name = "PlateOwner"
			plateOwner.Value = player.Name
			plateOwner.Parent = plate
			
			plater.Team = Contestants
			table.insert(PlayersAlive, player)
			table.insert(PlatesAlive, plate)
			for i, v in pairs(PlayersAlive) do print(i,v) end
			
			character.Humanoid.Died:Connect(function()
				print(player.Name.. " has died")
				player.Team = Spectators
				
				table.remove(PlayersAlive, table.find(PlayersAlive, player))
				table.remove(PlatesAlive, table.find(PlatesAlive, plate))
			end)
		else
			Status.Value = "Not enough players to start the game.."
		end
	end
	
	
	for i, plate in pairs(Plates:GetChildren()) do
		local plateOwner = plate:FindFirstChild("plateOwner")
		if not plateOwner then
			print("there is no owner")
			plate:Destroy()
		end
	end
	
	while #PlayersAlive > 0 do
		wait(timeBetweenEvents)
		
		local RandomMethodName = MethodNames[math.random(1, #MethodNames)]
		local Method = EventsModule[RandomMethodName]
		Method()
	end
	
	
	Plates:Destroy()
end

while true do
	intermission()
	startRound()
end

Is it saying it’s trying to index a nil value?
If that’s true then you’re not setting the PrimaryPart of the Plates when cloning.

Whenever you run :Clone() on Plate you have to make sure you assign the PrimaryPart.

and how do i do that? My brains not working 2da
It just says frame isn’t a valid member of model workspace.plates.i1

This should help you.