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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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.

0
so how to fix it? kanyeweasftd 14 — 3y
0
change line 6 to if Obby.Name == "Obby1" or Obby.Name == "Obby2" then DiamondComplex 285 — 3y
0
ok kanyeweasftd 14 — 3y
Ad

Answer this question