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

Why do I keep getting this error: Unable to cast Instance to CoordinateFrame?

Asked by 2 years ago

This is where the issue lies. I appreciate any help!

inround.Changed:Connect(function()
        for _, plr in pairs(players:GetPlayers()) do
            wait(0.5)
            if inround.Value == true then

                if forestmapworkspace.Value == true then
                    local character = plr.Character or plr.CharacterAdded:Wait()
                    local parts = maps:FindFirstChild("Forest"):FindFirstChild("TPParts")
                    local tpparts = "TPPart"
                    local randomtppart = math.random(1, 12)
                    local newtppart = "TPPart"..randomtppart
                    if randomtppart <= 12 then
                        character:SetPrimaryPartCFrame(parts:FindFirstChild((newtppart)))
                    else
                        print("Doesnt work")
                    end
                elseif mountainsmapworkspace.Value == true then
                    local character = plr.Character or plr.CharacterAdded:Wait()
                    local parts = maps:FindFirstChild("Mountains"):FindFirstChild("SpawnParts")
                    local tpparts = "SpawnPart"
                    local randomtppart = math.random(1, 15)
                    local newtppart = tpparts..randomtppart
                    print(newtppart)
                    if randomtppart <= 15 then
                        character:SetPrimaryPartCFrame(parts:FindFirstChild((newtppart)))
                    end

                else
                    print("Inround.Value == true doesnt work")
                end

            elseif inround.Value == false then
                local character = plr.Character or plr.CharacterAdded:Wait()
                local tpparts = game.Workspace:FindFirstChild("Lobby"):FindFirstChild("Spawns")
                local randomtppart = math.random(1, 5)  
                if randomtppart <= 5 then
                    character:SetPrimaryPartCFrame(tpparts:FindFirstChild("SpawnLocation"..randomtppart))
                end
            else
                print("Inround.Changed doesnt work")
            end



        end
    end)

Answer this question