Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does the game think that the camera's name is Obby1 or Obby2?

Whenever the player leaves the game, the script runs and it saves the obstacle course of the player. But it errors and says "Checkpoint is not a valid member of Camera "Workspace.Camera""

 game:GetService("Players").PlayerRemoving:Connect(function(player)
	local playerUserId = "Player_"..player.UserId
	local PlayerStages = {}
	
	for _, Obby in pairs(game:GetService("Workspace"):GetChildren()) do
		if Obby.Name == "Obby1" or "Obby2" then
			for __, SpawnLocation in pairs(Obby.Checkpoint:GetChildren()) do
				if SpawnLocation:IsA("SpawnLocation") then
					table.insert(PlayerStages, SpawnLocation, Obby)
				end
			end
		end
	end

1 answer

✓ Accepted answer

The problem is at line 6. You placed that when "Obby2" is 'true' which Lua will approve and the first instance to come up in the Workspace is the camera, it will get the camera instead.

3 comments

0

so how to fix it?

0

change line 6 to if Obby.Name == "Obby1" or Obby.Name == "Obby2" then

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.